django-q

Perform a logical exclusive OR on a Django Q object

Perform a logical exclusive OR on a Django Q object Question: I would like to perform a logical exclusive OR (XOR) on django.db.models.Q objects, using operator module to limit the choices of a model field to a subset of foreignkey. I am doing this in Django 1.4.3 along with Python 2.7.2. I had something like …

Total answers: 2

Django Tastypie Advanced Filtering: How to do complex lookups with Q objects

Django Tastypie Advanced Filtering: How to do complex lookups with Q objects Question: I have a basic Django model like: class Business(models.Model): name = models.CharField(max_length=200, unique=True) email = models.EmailField() phone = models.CharField(max_length=40, blank=True, null=True) description = models.TextField(max_length=500) I need to execute a complex query on the above model like: qset = ( Q(name__icontains=query) | Q(description__icontains=query) …

Total answers: 3

How to dynamically compose an OR query filter in Django?

How to dynamically compose an OR query filter in Django? Question: From an example you can see a multiple OR query filter: Article.objects.filter(Q(pk=1) | Q(pk=2) | Q(pk=3)) For example, this results in: [<Article: Hello>, <Article: Goodbye>, <Article: Hello and goodbye>] However, I want to create this query filter from a list. How to do that? …

Total answers: 14

How to combine multiple querysets in Django?

How to combine multiple querysets in Django? Question: I’m trying to build the search for a Django site I am building, and in that search, I am searching in three different models. And to get pagination on the search result list, I would like to use a generic object_list view to display the results. But …

Total answers: 16