Django: check query to get filters applied

Is there a way to check the query set and get information about which filters / exception were applied?

I need this for debugging: I cannot understand why my request does not include some data ...

+5
source share
2 answers

This is not easy to do. Each filter is applied differently to the query object, so you won’t find it clearly laid out "filter1", "filter2", "filter3".

Check out myqueryset.query.__dict__- the incoming filter is immediately divided into the corresponding areas and the record is not saved. Details c django.db.models.sql.query.Query.

I would check SQL instead.

print myqueryset.query 
+6
source

:

from django.db import connection
print connection.queries

, django, :

Django Debug

+2

All Articles