AttributeError: 'WSGIRequest' object has no attribute 'user'

2,560 views
Skip to first unread message

Tyson Tate

unread,
Oct 18, 2006, 9:17:15 PM10/18/06
to django...@googlegroups.com
I've been getting the following error quite frequently from Django
ever since I put up my Django site but haven't had the time to take a
deeper look at it until now.

Unfortunately, I'm at a loss as to what, exactly, is the problem here.

---

Traceback (most recent call last):

File "/home/ohgoditb/django_src/django/core/handlers/base.py",
line 74, in get_response
response = callback(request, *callback_args, **callback_kwargs)

File "/home/ohgoditb/django_src/django/views/generic/
date_based.py", line 333, in object_detail
}, context_processors)

File "/home/ohgoditb/django_src/django/template/context.py", line
97, in __init__
self.update(processor(request))

File "/home/ohgoditb/django_src/django/core/
context_processors.py", line 17, in auth
return {

AttributeError: 'WSGIRequest' object has no attribute 'user'

---

I've searched Google and the Groups archive but have found nothing
that works.

Perhaps someone on the list has a better idea of what's going on?

I've got the following in settings.py:

TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.auth",
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)

Thanks in advance for any ideas!

-Tyson

Jeremy Dunck

unread,
Jan 4, 2007, 11:17:19 PM1/4/07
to django...@googlegroups.com
On 10/18/06, Tyson Tate <ty...@fallingbullets.com> wrote:
...

> I've got the following in settings.py:
>
> TEMPLATE_CONTEXT_PROCESSORS = (
> "django.core.context_processors.debug",
> "django.core.context_processors.i18n",
> "django.core.context_processors.auth",
> )
>
> MIDDLEWARE_CLASSES = (
> 'django.middleware.common.CommonMiddleware',
> 'django.contrib.sessions.middleware.SessionMiddleware',
> 'django.contrib.auth.middleware.AuthenticationMiddleware',
> 'django.middleware.doc.XViewMiddleware',
> 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
> )
>
> Thanks in advance for any ideas!

Sorry, I'm stumped. :-/

Brian Beck

unread,
Jan 4, 2007, 11:40:56 PM1/4/07
to Django users
It would seem that something is happening between the authentication
middleware setting request.__class__.user and the context processor
reading it.

Couple things to try if you're in a debugging mood:

After line 11 in django/contrib/admin/middleware.py:
request.__class__.user = LazyUser()
+ print 'Middleware:', request.user

Add that line to see if it's actually being set.

Now as the first line in whatever view this is happening in, do the
same thing:

def index_view(request):
+ print 'View:', request.user

This should at least narrow down where in the code request.user is
being obliterated...

Sam

unread,
Jan 15, 2007, 12:35:02 PM1/15/07
to Django users
I had this error because i'm not using the auth module.

If that's you case, comment it out in your settings.py file:

TEMPLATE_CONTEXT_PROCESSORS = (
"django.core.context_processors.debug",
"django.core.context_processors.i18n",

# "django.core.context_processors.auth",
)

On Jan 5, 5:40 am, "Brian Beck" <exo...@gmail.com> wrote:
> It would seem that something is happening between the authentication

> middleware setting request.__class__.userand the context processor


> reading it.
>
> Couple things to try if you're in a debugging mood:
>
> After line 11 in django/contrib/admin/middleware.py:

> request.__class__.user= LazyUser()

Reply all
Reply to author
Forward
0 new messages