문제

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?

도움이 되었습니까?

해결책

Looks like Something is already a QuerySet

Just do

qs = Something.filter(**conditions)
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top