Sunday, September 11, 2022

Re: How to Filter Children Model In Django RestFramework

Just use that foreign key field name with double underscore filter field name. For example - you have a parent model ClassRoom having it's children model Student which is referred as student fk in ClassRoom. So if you want to filter student name from ClassRoom api then you can just write : filterset_fields = {student__name: ["istartswith", icontaints], }

On Sun, Sep 11, 2022, 1:04 PM Renfer Richards <personalrenfer.richards@gmail.com> wrote:
https://stackoverflow.com/q/73677543/19855555

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/10326702-a0de-49dd-9245-c41719f754b7n%40googlegroups.com.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFOSuX%2BXcnK0GY3CBE5UgJFFoAQyq7L0uqW%2BW74YLNyMVm6SUA%40mail.gmail.com.

No comments:

Post a Comment