import operator
from django.db.models import Q
User.objects.filter(reduce(operator.and_, (Q(first_name__contains=x) for x in ['x', 'y', 'z'])))
for python 3
from functools import reduce
.
More Related Contents:
- How to set a Django model field’s default value to a function call / callable (e.g., a date relative to the time of model object creation)
- What does on_delete do on Django models?
- Dynamic File Path in Django
- Django: Populate user ID when saving a model
- Get model’s fields in Django
- Can django’s auth_user.username be varchar(75)? How could that be done?
- How to ‘bulk update’ with Django?
- Using a UUID as a primary key in Django models (generic relations impact)
- Custom QuerySet and Manager without breaking DRY?
- Django ManyToMany filter()
- Django delete FileField
- Why does django’s prefetch_related() only work with all() and not filter()?
- ImageField overwrite image file with same name
- Django “xxxxxx Object” display customization in admin action sidebar
- How to limit queryset/the records to view in Django admin site?
- How to assign currently logged in user as default value for a model field?
- How to register users in Django REST framework?
- Using Django auth UserAdmin for a custom user model
- Django ManyToMany model validation
- Django – Overriding the Model.create() method?
- Django : Unable to import model from another App
- django.db.utils.IntegrityError: UNIQUE constraint failed: rango_category__new.slug
- Can Django automatically create a related one-to-one model?
- Django Order By Date, but have “None” at end?
- How to add a sortable count column to the Django admin of a model with a many-to-one relation?
- Password field in Django model
- Creating Partial Indexes with Django 1.7
- Django: dynamic database file
- conversion of datetime Field to string in django queryset.values_list()
- Django Rest framework, how to include ‘__all__’ fields and a related field in ModelSerializer ?