question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Django 1.11 - Decorator for class-based views in urls.py

See original GitHub issue

Django 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:closed
  • Created 6 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
kencochranecommented, Aug 2, 2017

@felixkohtz FYI 0.5.1 has been pushed to pypi.

0reactions
kencochranecommented, Aug 2, 2017

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.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found