13👍
✅
That doesn’t seem easy to do. Each filter is applied differently to the query object so you’re not going to find a cleanly laid out "filter1", "filter2", "filter3"
.
Check out myqueryset.query.__dict__
– the incoming filter is separated into relevant areas immediately and no record stored. Details in django.db.models.sql.query.Query
.
I’d check out the SQL instead.
print myqueryset.query
3👍
You can use also:
your_qs.query.where.children
or:
your_qs._has_filters().__dict__['children']
and to access to the first filter that you applied:
your_qs._has_filters().__dict__['children'][0].__dict__
- Override data validation on one django form element
- Django Rest Framework use DjangoModelPermissions on ListAPIView
- Conditionally Require Only One Field In Django Model Form
- What does it mean for an object to be unscriptable?
2👍
If you are debugging in a shell:
from django.db import connection
print connection.queries
If you are making requests in a browser use django debug toolbar, it’s a great tool and can be very helpful:
- "The connection was reset" in localhost:8000 using django and docker
- Django: Accessing request in forms.py clean function
- Django – Polymorphic Models or one big Model?
- ImportError: No module named rest_framework_jwt.views
Source:stackexchange.com