I use @login_required decorator in my project from day one and it works fine, but for some reason I start getting an "AttributeError: the unicode object does not have a user attribute on some specific URLs (and those that worked in the past).
Example. I am a website registered and then click the link and I get this error, which is usually due to the fact that SessionMiddleware is not installed. But in my case, there is one, since I went to the site and on the page I am on was also @login_required.
Any idea?
The URL is defined as: (r'^accept/(?P<token>[a-zA-Z0-9_-]+)?$', 'accept'), and the method as: @login_required def accept(request,token): ...
Tracking:
Traceback (most recent call last): File "/Users/macbook/virtualenv/proj/lib/python2.6/site-packages/django/core/servers/basehttp.py", line 674, in __call__ return self.application(environ, start_response) File "/Users/macbook/virtualenv/proj/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 241, in __call__ response = self.get_response(request) File "/Users/macbook/virtualenv/proj/lib/python2.6/site-packages/django/core/handlers/base.py", line 141, in get_response return self.handle_uncaught_exception(request, resolver, sys.exc_info()) File "/Users/macbook/virtualenv/proj/lib/python2.6/site-packages/django/core/handlers/base.py", line 165, in handle_uncaught_exception return debug.technical_500_response(request, *exc_info) File "/Users/macbook/virtualenv/proj/lib/python2.6/site-packages/django/core/handlers/base.py", line 100, in get_response response = callback(request, *callback_args, **callback_kwargs) File "/Users/macbook/virtualenv/proj/lib/python2.6/site-packages/django/contrib/auth/decorators.py", line 25, in _wrapped_view return view_func(request, *args, **kwargs) File "/Users/macbook/dev/pycharm-projects/proj/match/views.py", line 33, in accept return __process(token,callback) File "/Users/macbook/virtualenv/proj/lib/python2.6/site-packages/django/contrib/auth/decorators.py", line 24, in _wrapped_view if test_func(request.user): AttributeError: 'unicode' object has no attribute 'user'`