How to Filter Children Model In Django RestFramework

25 views
Skip to first unread message

Renfer Richards

unread,
Sep 11, 2022, 3:33:57 AM9/11/22
to Django users

Abhineet Baranwal

unread,
Sep 11, 2022, 4:13:54 AM9/11/22
to django...@googlegroups.com
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 <personalren...@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...@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.
Reply all
Reply to author
Forward
0 new messages