Answer the question
In order to leave comments, you need to log in
Outputting multiple models in one Django template?
Good day! I'm making a Django forum and I've run into a problem. There is a simple view that is responsible for the main content of the main forum page:
class SectionsListView(ListView):
template_name = 'sections.html'
queryset = Section.objects.all()
def get_category(self):
return Category.objects.filter(section_category=self)
def get_topic_count(self):
topic_count = 0
themes = Theme.objects.filter(category_theme=self)
for theme in themes:
topic_count += theme.get_topic().count()
return topic_count
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question