calm-queen-64495
08/22/2022, 2:07 AMclass RolesList(ListView):
model = Role
template_name = 'workers-roles.html'
# context_object_name = 'roles'
def get_template_names(self):
if self.request.htmx:
return 'partials/roles_list.html'
return self.template_name
def get_context_data(self, **kwargs):
# Call the base implementation first to get a context
context = super().get_context_data(**kwargs)
# Add in a QuerySet of all the Roles
context['roles'] = Role.objects.all().order_by('name')
return context