Linked Questions
91 questions linked to/from How to combine multiple QuerySets in Django?
4
votes
2
answers
8k
views
How to merge multiple query sets in DJANGO [duplicate]
I have to merge the querysets below in a single list:
result_list_1 = Col.objects.defer("tags").filter(producer__username__icontains=crit)
result_list_2 = Col.objects.defer("tags").filter(...
0
votes
1
answer
306
views
How to combine multiple querysets in django [duplicate]
Suppose there is an event model and for each event there is one client and one consultant. Also, one consultant can have multiple events. Each event has number of different documents. I am trying to ...
2
votes
0
answers
177
views
Django, merging two objects [duplicate]
I have two objects
article_category = ArticleCategory.objects.all()
project_category = ProjectCategory.objects.all()
I want to merge these two in one so that I can access them with one object.
...
1
vote
0
answers
99
views
mixing related objects django [duplicate]
I have something like this in my models.py:
class Section(models.Model):
title = models.CharField(max_length=50)
class Lesson1(models.Model):
section = models.ForeignKey(Section)
title = ...
131
votes
4
answers
87k
views
How can I find the union of two Django querysets?
I’ve got a Django model with two custom manager methods. Each returns a different subset of the model’s objects, based on a different property of the object.
Is there any way to get a queryset, or ...
40
votes
3
answers
50k
views
how to create an empty queryset and to add objects manually in django [closed]
I need to create a queryset and to add manually some objects that i've got from different queries results in order to display it in a table.
I uses xx=set() but it doesn't do the job.
26
votes
4
answers
32k
views
ForeignKey to multiple Models or Queryset
Is it possible to make a ForeignKey to more than one model? I want to choose from different models like Parts and Machines Model.
I read this to combine multiple models into one list: How to combine ...
10
votes
6
answers
11k
views
Return exact matches at top of Django Queryset
I have a django model, called "User" which stores some basic information about people, namely first and last name. I currently have a simple search across my django model where, if a user types in a ...
8
votes
2
answers
21k
views
Django, how to use filter to check if string field is contained in parameter
Say, I have a model with a text field:
class SomeModel
keyword=models.CharField(null=True, max_length=255)
Now, I know how to check if a parameter string (lets call the variable "querystring" is ...
8
votes
2
answers
6k
views
Manually combine multiple Django QuerySets, and serialize result using DRF
I have been researching this for a couple days. Unfortunately, all of the proposed solutions I have found so far don't exactly work for me.
I am looking to manually combine two Django QuerySets into ...
2
votes
2
answers
11k
views
Django: union of different queryset on the same model
I'm programming a search on a model and I have a problem.
My model is almost like:
class Serials(models.Model):
id = models.AutoField(primary_key=True)
code = models.CharField("Code", ...
7
votes
1
answer
8k
views
Django multiple queryset combine into a pagination
I have combine 2 queryset from different models into a list and used pagination to display as a single list.
The problem is the objects from the list are displayed by the pagination according to the ...
2
votes
2
answers
5k
views
Creating a queryset which represents a union of querysets
Let's say I have the following models:
class House(models.Model):
address = models.CharField(max_length=255)
class Person(models.Model):
name = models.CharField(max_length=50)
home = ...
7
votes
3
answers
2k
views
Populating a tastypie resource for a multi-table inheritance Django model
Given the following code I was wondering how to populate RecordsResource with each real record data:
models.py
class Record(models.Model):
content_type = models.ForeignKey(ContentType, editable=...
3
votes
2
answers
4k
views
How to use Django QuerySet.union() in ModelAdmin.formfield_for_manytomany()?
Not sure what I am doing wrong here:
I tried to use QuerySet.union(), in Django 2.2.10, to combine two querysets (for the same model) inside ModelAdmin.formfield_for_manytomany(). However, when the ...