Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!
How can you create a custom mixin for a Django class-based view that changes the template based on the user's role and department? Fill the blanks in code to make this work.Built-in and custom mixins for Class Based Views
Role-based view sorcery unveiled
Report a typo
Fill in the gaps with the relevant elements
DynamicTemplateMixin:
get_template_names(self):
user = self.request.user
base_template = 'base_template.html'
role_template = 'staff.html' if user.is_staff else 'regular.html'
[f'{user.department}/{role_template}', base_template]Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.