Skip to content

Commit

Permalink
feat: filterfield api
Browse files Browse the repository at this point in the history
  • Loading branch information
delitamakanda committed Jan 23, 2022
1 parent 8b0eeb4 commit bb4f786
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 5 additions & 1 deletion buyers_panel/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,9 @@ class OrderViewSet(viewsets.ModelViewSet):


class BillingAddressViewSet(viewsets.ModelViewSet):
queryset = BillingAddress.objects.all()
serializer_class = BillingAddressSerializer
queryset = BillingAddress.objects.all()

def get_queryset(self):
billing_addresses = BillingAddress.objects.filter(user=self.request.user)
return billing_addresses
4 changes: 2 additions & 2 deletions grocers_panel/api/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ class ShopViewSet(viewsets.ModelViewSet):
queryset = Shop.objects.all()
serializer_class = ShopSerializer
filter_backends = [DjangoFilterBackend, SearchFilter]
filterset_fields = ['tags__name']
search_fields = ['^name', 'about', '^food__meals__name']
filterset_fields = ['tags__name', 'distance', 'food__meals__category', 'food__meals__label']
search_fields = ['^name', '^about', '^food__category', '^food__meals__name', '^tags__name']


class OfferViewSet(viewsets.ModelViewSet):
Expand Down

0 comments on commit bb4f786

Please sign in to comment.