My question is a general one, but specifically my application is the login_required decorator for Django.
I’m curious if there is a way to check if a view/function has a specific decorator (in this case the login_required decorator)
I am redirecting after logging a user out, and I want to redirect to the main page if the page they are currently on has the login_required decorator. My searches have yielded no results so far.
Build your own
login_requireddecorator and have it mark the function as decorated–probably the best place to mark it would be in thefunc_dict.Now you can check to see if a view was decorated like this…
If you’re confused about Python decorators see this SO question/answer: How to make a chain of function decorators?