python - Django model complex filter -


this model attributes:

    name, version, date_added, last_modified 

i have list this:

    [(name1, version1), (name2, version2), (name3, version3)...] 

i want filter model (name, version) tuple. how can that?

you can way:

from operator import or_ django.db.models import q  l = [(name1, version1), (name2, version2), (name3, version3)...]  data = yourmodel.objects.filter(reduce(or_, q(name=name, version=version)                                             name, version in l)) 

i think both in in sql , django orm designed single field.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -