Filtering API Rest Framework Django (Extra Field FK)


I would like to be able to filter by the value of another field in the table (FK) not only by id

Right now if I write link it returns the results I want , but I would like to be able to filter in the following way (for another field of the FK (Table languages field shortname) link

On the other hand I have managed to filter a normal table by another field without many problems, including several parameters. But in a related table ... I do not know how to do it.


In this case I filtered from the table answers those that are of question 1 and have content 'PHP'. I would like to do exactly the same thing but filtering by fields of the related table.

The thing is that I have to return all the questions with their respective answers filtered by language or by category. I'll have to use the Django Rest Framework Multiple Models * ??? To be able to cross the tables?

asked by RuralGalaxy 23.05.2016 в 13:18

1 answer


After you have configured your filter you can do the filters as if it were a queryset using the low double dash notation (__). Examples:
answered by 30.10.2016 в 02:56