I know the relative url (ie. /accounts/) and from that I'd like to determine whether or not the view that handles it is decorated with the login_required decorator.
Asked
Active
Viewed 93 times
1 Answers
0
You can get the corresponding view from an URL using django.urls.resolve.
As of determining how it was decorated, this is impossible. A decorator is the application of a function, not some sort of flag.
However you can redefine your own login_required decorator that calls the original login_required AND sets a custom attribute to the view: view.is_login_required = True.
Antoine Pinsard
- 28,811
- 7
- 58
- 82