'Django get_context_data doesn't work in templates
I am trying to loop over 2 queryes in a django template and only one works. I tried using get_centext_data method and alos the context_object_name variable and it doesn' t work.
Code :
class HomeView(LoginRequiredMixin, ListView):
model = Resorts
template_name = 'aplicatie2/home.html'
context_object_name = 'high_rated_resorts'
def get_queryset(self):
return Resorts.objects.filter(rating__gte = 4.6)
class VisitedListView(ListView):
model = AdditionalInformationModel
template_name = 'aplicatie2/home.html'
context_object_name = 'visited_resorts_list'
def get_queryset(self):
return AdditionalInformationModel.objects.filter(user = self.request.user)
the for loop using high_rated_resorts works, while a for loop over visited_resorts_list doesn't show anything. I tried using the same logic with get_context_data but with no luck.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
