#25798: RedirectView providing different request object to decorator
-------------------------------+-----------------------
Reporter: connexion2000 | Owner: nobody
Type: Bug | Status: new
Component: Uncategorized | Version: 1.9rc1
Severity: Normal | Keywords: decorator
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+-----------------------
I have my own simple decorator:
{{{
def ensure_user_has_profile(view_func):
def _decorator(request, *args, **kwargs):
if request.user:
if request.user.is_authenticated():
if not hasattr(request.user, 'profile'):
profile = Profile()
profile.user = request.user
profile.save()
response = view_func(request, *args, **kwargs)
return response
return wraps(view_func)(_decorator)
}}}
However when RedirectView is decorated with above decorator it causes an
error:
{{{
'HomeView' object has no attribute 'user'
}}}
to make it work I need to access user by typing: request.request.user.
Then it works with RedirectView, but not with other views.
--
Ticket URL: <https://code.djangoproject.com/ticket/25798>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/056.05dc235fe80da6046df7ce2ed351eb00%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.