user504909
user504909

Reputation: 9549

How to make django QuerySet will dynamic filter?

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?

Upvotes: 1

Views: 170

Answers (1)

karthikr
karthikr

Reputation: 99620

Looks like Something is already a QuerySet

Just do

qs = Something.filter(**conditions)

Upvotes: 2

Related Questions