Answer the question
In order to leave comments, you need to log in
Is it possible to optimize the number of requests using Django ORM?
There is a model that uses Content type
models.py
class Issue(models.Model):
body = models.TextField()
content_type = models.ForeignKey(
ContentType,
limit_choices_to={'model__in': ('first_model', 'second_model'))
object_id = models.PositiveIntegerField()
content_object = GenericForeignKey('content_type', 'object_id')
class IssueListView(ListView):
queryset = Issue.objects.select_related('content_type')
Answer the question
In order to leave comments, you need to log in
.prefetch_related('content_object')
It is he who supports the prefetch of dynamic links .
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question