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?

Était-ce utile?

La solution

Looks like Something is already a QuerySet

Just do

qs = Something.filter(**conditions)
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top