If i have a class based view like:
class equipmentdashboardView(LoginRequiredMixin,ListView):
context_object_name = 'equipmentdashboard'
template_name = 'equipmentdashboard.html'
login_url = 'login'
def get_queryset(self):
#some stuff
How can I change the template_name depending on a query? I want to do something like:
class equipmentdashboardView(LoginRequiredMixin,ListView):
context_object_name = 'equipmentdashboard'
if self.request.user.PSScustomer.customerName == 'Customer X':
template_name = 'equipmentdashboard_TL.html'
else:
template_name = 'equipmentdashboard.html'
login_url = 'login'
def get_queryset(self):
#some stuff
But you can't access the request before the get_queryset.
Or maybe there is an even simpler way of achieving the same behavior?