Linked Questions

4 votes
2 answers
8k views

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(...
Miki's user avatar
  • 1,869
0 votes
1 answer
306 views

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 ...
YASH JARIWALA's user avatar
2 votes
0 answers
177 views

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. ...
S7H's user avatar
  • 1,655
1 vote
0 answers
99 views

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 = ...
SaulTigh's user avatar
  • 963
131 votes
4 answers
87k views

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 ...
Paul D. Waite's user avatar
40 votes
3 answers
50k views

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.
user2137817's user avatar
  • 1,851
26 votes
4 answers
32k views

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 ...
Harry's user avatar
  • 13.4k
10 votes
6 answers
11k views

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 ...
Chad's user avatar
  • 1,864
8 votes
2 answers
21k views

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 ...
RVC's user avatar
  • 439
8 votes
2 answers
6k views

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 ...
John Cleveland's user avatar
2 votes
2 answers
11k views

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", ...
Giovanni Di Milia's user avatar
7 votes
1 answer
8k views

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 ...
donkeyboy72's user avatar
  • 1,963
2 votes
2 answers
5k views

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 = ...
Krystian Cybulski's user avatar
7 votes
3 answers
2k views

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=...
Juan Riaza's user avatar
  • 1,648
3 votes
2 answers
4k views

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 ...
djvg's user avatar
  • 14.8k

15 30 50 per page
1
2 3 4 5
7