Django Filter

27 views
Skip to first unread message

Nirali Supe

unread,
Jun 30, 2018, 11:44:05 PM6/30/18
to Django REST framework
Hello,

class JobsFilter(filters.FilterSet):
 
class Meta:
 model
= Jobs
 fields
= {'id': ['exact', 'lt', 'gt'],
 
'runs': ['exact', 'in', 'lt', 'gt'],
 
}
class JobsViewSet(viewsets.ModelViewSet):
 
"""
 List all Entries, or create a new one.
 """

 queryset
= Jobs.objects.all()
 serializer_class
= JobsSerializer
 filter_backends
= (filters.DjangoFilterBackend,)
 filter_class
= JobsFilter

The following url is working:

But I need the url in the following format:
Is there a way I can do that?

Jason

unread,
Jul 1, 2018, 8:22:33 AM7/1/18
to Django REST framework
django filters uses django's lookup format to execute the filtering on the models.  while I suspect what you want can be done, its going to require you to make your own query parser ad transform it to the format filters expects for the lookups.  Is that really a good way to spend your time?
Reply all
Reply to author
Forward
0 new messages