I have successfully implemented django-filter on my Django-rest-framework server.
I have the following filter_class
filters.py
class EmploymentFilter(filters.FilterSet):
class Meta:
model = EmploymentCheck
fields = ['instructions',]
views.py
class EmploymentCheckViewSet(viewsets.ModelViewSet):
pagination_class = ContentRangeHeaderPagination
serializer_class = EmploymentCheckSerializer
queryset = EmploymentCheck.objects.all()
filter_class = EmploymentFilter
the filter works when i send a get request as
/employmentcheck/?instructions=2
However, I have implemented a front end with react-admin.
My front-end, sends a request with the url_params as objects
/employmentcheck/?filter={"instruction_id":"2"}&range=[0,24]&sort=["id","DESC"]/
Notice how the URL specifies a filter object, in which, it defines the parameters to filter against.
My question is, how and where can I filter my model without changing the URL pattern from my client?
Any other advise that spans the scope of my question is equally welcomed
Models.py
class EmploymentCheck(models.Model):
instructions = models.ForeignKey(Instruction, on_delete=models.CASCADE, null=True)