I've used Django REST Framework for quite a while now, but have come across a situation where I need to retrieve everything but a known relation in an API view. After looking through the documentation again, I cannot see any built-in mechanism to achieve this. I realize I can override get_queryset()
in my ListView and parse custom URL query parameters and then do the filtering, but I'm curious if anyone else has a more elegant solution?
Update
After a little more research, this seems to be more of a django-filter question, and I cannot find mention of any exclude functionality. I did find this:
https://bitbucket.org/mjs7231/django-rest-framework-filtering
which does provide excluding values from the results.
It sounds like you are searching for custom filter backend