Remove those counts because I can just use |length
This commit is contained in:
parent
94b54a0ef2
commit
1e868efb72
@ -23,14 +23,14 @@ class IndexView(TemplateView):
|
|||||||
ctx = super().get_context_data()
|
ctx = super().get_context_data()
|
||||||
|
|
||||||
# Get show by abbreviation, add episode count to the show and return only the first object
|
# Get show by abbreviation, add episode count to the show and return only the first object
|
||||||
show = Show.objects.filter(abbr=abbreviation).annotate(episode_count=Count('episodes')).first()
|
show = Show.objects.filter(abbr=abbreviation).first()
|
||||||
|
|
||||||
# 404
|
# 404
|
||||||
if not show:
|
if not show:
|
||||||
raise Http404("Show does not exist")
|
raise Http404("Show does not exist")
|
||||||
|
|
||||||
# Get all seasons of the show and annotate episode counts onto them
|
# Get all seasons of the show and annotate episode counts onto them
|
||||||
seasons = show.seasons.all().annotate(episode_count=Count('episodes'))
|
seasons = show.seasons.all()
|
||||||
|
|
||||||
# Add fields to context
|
# Add fields to context
|
||||||
ctx['show'] = show
|
ctx['show'] = show
|
||||||
|
Reference in New Issue
Block a user