#16626: login_required attribute in class-based Generic Views -------------------------------------+------------------------------------- Reporter: szczav | Owner: nobody Type: New feature | Status: closed Component: Generic views | Version: master Severity: Normal | Resolution: Keywords: login_required | worksforme decorator view generic views | Triage Stage: Has patch: 1 | Unreviewed Needs tests: 0 | Needs documentation: 0 Easy pickings: 0 | Patch needs improvement: 0 | UI/UX: 0 -------------------------------------+-------------------------------------
Comment (by jarus): With the `@classmethod` decorader the code example works fine. {{{ from django.contrib.auth.decorators import login_required class LoginRequiredMixin(object): @classmethod def as_view(cls): return login_required(super(LoginRequiredMixin, cls).as_view()) }}} I aggree with aaugustin that a mixin is the better solution instead a attribute in the generic view but maybe it is possible to put this mixin in `django.contrib.auth`. -- Ticket URL: <https://code.djangoproject.com/ticket/16626#comment:3> Django <https://code.djangoproject.com/> The Web framework for perfectionists with deadlines. -- You received this message because you are subscribed to the Google Groups "Django updates" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/064.0d6bab2b621e469215598fc304e891d1%40djangoproject.com?hl=en. For more options, visit https://groups.google.com/groups/opt_out.