Answer the question
In order to leave comments, you need to log in
How to create a filter for objects displayed through the ListView?
The ListView displays all objects in the University model.
The University model has a city field.
How to output only university with a specific city value with help?
Answer the question
In order to leave comments, you need to log in
class UniversityListView(ListView):
...
def get_queryset(self):
university = University.objects.filter(city='London')
return university
class University(models.Model):
...
city = models.ForeignKey('City')
...
class UniversityListView(ListView):
...
def get_queryset(self):
city = City.objects.get(name='London')
university = University.objects.filter(city=city)
return university
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question