Description
Thesis.__str__() in django/apps/thesis/models/thesis.py calls self.authors.all(), which fires a database query every time the thesis is converted to a string.
def __str__(self):
return '{}: {}'.format(', '.join(str(a) for a in self.authors.all()), self.title)
In admin views, logging, serializer __repr__, or anywhere theses are listed, this creates an N+1 query problem — one extra query per thesis instance.
Severity
Medium — performance degradation, especially in admin and logging contexts.
Location
django/apps/thesis/models/thesis.py — __str__()
Fix
Either cache the author names on the model, use prefetch_related('authors') consistently, or simplify __str__ to not require the relation (e.g., use self.title only).
Description
Thesis.__str__()indjango/apps/thesis/models/thesis.pycallsself.authors.all(), which fires a database query every time the thesis is converted to a string.In admin views, logging, serializer
__repr__, or anywhere theses are listed, this creates an N+1 query problem — one extra query per thesis instance.Severity
Medium — performance degradation, especially in admin and logging contexts.
Location
django/apps/thesis/models/thesis.py—__str__()Fix
Either cache the author names on the model, use
prefetch_related('authors')consistently, or simplify__str__to not require the relation (e.g., useself.titleonly).