Closed aschriner closed 10 years ago
Totally my mistake: decorator should look like @method_decorator(allow_lazy_user)
instead.
aschriner I got the same problem. Can you please explain your solution?
I was watching https://github.com/danfairs/django-lazysignup/blob/master/lazysignup/tests.py#L66
and as far as I can see (also on the documentation) I should use the decorator as
@allow_lazy_user
def lazy_view(request):
r = HttpResponse()
if request.user.is_anonymous() or request.user.has_usable_password():
r.status_code = 500
return r
Cheers, Ema.
Ema,
The difference is whether your view is a function based view or class based view. If it's a class based view, you need to use the method_decorator
decorator on the dispatch
method. If it's a function based view, then I don't know what the issue is.
I am trying to use the
allow_lazy_user
decorator on the dispatch method of a class- based view.but I am getting
AssertionError: You need to have the session app intsalled
. I do have the session app installed, and I do have it in the MIDDLEWARE_CLASSES setting. If I putimport pdb;pdb.set_trace()
inside the dispatch method I can verify thathasattr(request, "session")
isTrue
.