Computer scienceBackendDjangoDjango fixes

Built-in and custom mixins for Class Based Views

Theory

Crafting the perfect view puzzle

Report a typo
Hey there! This problem might be a bit unpredictable, but give it a go and let us know how you do!
How would you complete the ComplexDetailView class to create a view that displays and updates a CustomModel object, while also checking for user permissions? Fill in the blanks in the code to make it work correctly.
Fill in the gaps with the relevant elements
class ComplexDetailView(, , , ):
    model = CustomModel
    template_name = 'complex_detail.html'
    form_class = CustomForm
    success_url = reverse_lazy('success_page')
    def get_object(self, queryset=None):
        obj = ().get_object(queryset)
        if not self.request.user.has_perm('app.change_custommodel'):
            raise PermissionDenied()
        return obj

Create a free account to access the full topic