Answer the question
In order to leave comments, you need to log in
How to display objects of another model in a ListView model?
There is a University model and a City model.
In views.py we create a ListView for University.
How in the ListVIew template to display objects of the City model?
Answer the question
In order to leave comments, you need to log in
class UniversityListview(ListView):
...
def get_context_data(self, **kwargs):
ctx = super(UniversityListView, self).get_context_data(**kwargs)
ctx['cities'] = City.objects.all()
return ctx
...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question