diff options
-rw-r--r-- | models.py | 7 | ||||
-rw-r--r-- | views.py | 2 |
2 files changed, 8 insertions, 1 deletions
@@ -62,7 +62,14 @@ class Source(models.Model): verbose_name_plural = "sources d’emploi du temps" +class TimetableManager(Manager): + def get_queryset(self): + return super(Manager, self).get_queryset().select_related("year") + + class Timetable(SlugModel): + objects = TimetableManager() + year = models.ForeignKey(Year, on_delete=models.CASCADE, verbose_name="année") name = models.CharField(max_length=64, verbose_name="nom") @@ -31,7 +31,7 @@ def index(request): def mention_list(request, year_slug): year = get_object_or_404(Year, slug=year_slug) - timetables = Timetable.objects.order_by("name").filter(year=year).select_related("year") + timetables = Timetable.objects.order_by("name").filter(year=year) return render(request, "index.html", {"year": year, "elements": timetables}) |