What is the SIMPLEST method for getting 2 models to be listed in a generic IndexView? My two models are CharacterSeries
and CharacterUniverse
.
My views.py
from .models import CharacterSeries, CharacterUniverse
class IndexView(generic.ListView):
template_name = 'character/index.html'
context_object_name = 'character_series_list'
def get_queryset(self):
return CharacterSeries.objects.order_by('name')
class IndexView(generic.ListView):
template_name = 'character/index.html'
context_object_name = 'character_universe_list'
def get_queryset(self):
return CharacterUniverse.objects.order_by('name')
I need to know the shortest and most elegant code. Looked a lot but don't want to use mixins. I am perhaps not being pointed in the right direction.
Thanks all.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…