Question

I have a query that looks like this:

conditions={'sector': u'65', 'tax_type': u'cleaning', 'district': u'22'}
qs = Something.objects.filter(**conditions)

But there raise an error:

'QuerySet' object has no attribute 'objects'

How can I make the dynamic queryset with dictionary contain the filter name and conditions in django?

Was it helpful?

Solution

Looks like Something is already a QuerySet

Just do

qs = Something.filter(**conditions)
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top