Hi Simon,
Thanks for the clarification of the operation of the .union() method - the
operative phrase in the docs appears to be "combine the results of two or
more QuerySets" - perfect!
My project is currently using 1.8 LTS - I can defer this until I roll
forward to 1.11 LTS (hopefully sometime
Hello Richard,
Since Django 1.11 you should be able to use the QuerySet.union() method[0]
for that.
queryset = self.many_field1.order_by('some', 'fields')
combined = queryset.union(self.many_field2.order_by('some', 'fields'))
Best,
Simon
[0]
Hi,
I am combining querysets of the same model in the following manner:
class ExampleModel(models.Model):
many_field1 = models.ManyToManyField('Model', related_name='name1')
many_field2 = models.ManyToManyField('Model', related_name='name2')
def combined_many_fields(self):
3 matches
Mail list logo