Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django: inspect queryset to get applied filters

Is there a way to inspect a queryset and get info about which filters/exclude have been applied?

I need it for debugging: I cannot understand why my queryset excludes some data...

like image 549
Don Avatar asked Oct 27 '11 13:10

Don


1 Answers

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__
like image 74
asmatrk Avatar answered Oct 05 '22 07:10

asmatrk