Django 1.11 - Decorator for class-based views in urls.py
See original GitHub issueDjango 1.11.4
I am using class-based views for my login.
From the Django docs - “The login function-based view should be replaced by the class-based”: https://docs.djangoproject.com/en/1.11/topics/auth/default/#django.contrib.auth.views.LoginView
Since i can’t find a documentation or figure out how to decorate a class-based view, how would i do it in urls.py ?
urls.py
from defender.decorators import watch_login
urlpatterns = [
...
url(r'^login/$', auth_views.LoginView.as_view(), name='login'),
]
Regards
Issue Analytics
- State:
- Created 6 years ago
- Comments:9 (3 by maintainers)
Top Results From Across the Web
Introduction to class-based views - Django documentation
To decorate every instance of a class-based view, you need to decorate the class definition itself. To do this you apply the decorator...
Read more >Django Decorator Attribute Error for Class Based Views
I'm trying to use a decorator on the dispatch methods of several Class Based Views in my Django app. Here is one example...
Read more >Class-based generic views — Django 1.4.22 documentation
Class-based generic views (and any class-based views that inherit from the base classes Django provides) can be configured in two ways: ...
Read more >Class-Based Views vs. Function-Based Views
For example, if you created a view extending the django.views.View base class, the dispatch() method will handle the HTTP method logic. If the ......
Read more >Creating and Utilizing Decorators in Django - Section.io
To add a decorator function to every instance of a class-based view, you need to decorate the class definition itself. To do this,...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found

@felixkohtz FYI 0.5.1 has been pushed to pypi.
Thanks for the reminder, I should push out a 0.5.1 release with what is currently on master. I haven’t heard any complaints so it is probably good to go.