#6699 closed (invalid)
contrib.auth decorators aren't using proper decorator syntax
Reported by: | Chris Beaven | Owned by: | nobody |
---|---|---|---|
Component: | Contrib apps | Version: | dev |
Severity: | Keywords: | ||
Cc: | Triage Stage: | Unreviewed | |
Has patch: | no | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
The related documentation (http://www.djangoproject.com/documentation/authentication/#the-login-required-decorator) is totally incorrect. Neither of the 2.3 or 2.4 decoration methods stated will work:
my_view = login_required(redirect_field_name='redirect_to')(my_view) @login_required(redirect_field_name='redirect_to')
since the definition is:
def login_required(function=None, redirect_field_name=REDIRECT_FIELD_NAME):
Other decorator methods in this are also wrong.
Change History (3)
comment:1 by , 17 years ago
comment:2 by , 17 years ago
Resolution: | → invalid |
---|---|
Status: | new → closed |
This is mistaken. Notice that login_required behaves differently based on whether function is passed in or not: one case returns a decorator (function=None), the other returns the decorated function.
comment:3 by , 17 years ago
Duh... I typed this up while answering an IRC problem without obviously looking too closely at the code. Sorry for the noise, Malcolm.
#6700, has a possible solution.