Django filter applied when kwargs else return all
You can filter with:
class TeamListView(ListView):
"""View to display all or filtered teams."""
model = Team
def get_queryset(self):
qs = super().get_queryset()
if 'country' in self.kwargs:
return qs.filter(country=self.kwargs['country'])
return qs # 🖘 otherwise return the entire queryset