'WSGIRequest' object has no attribute 'user' (Creating my first admin site)

937 views
Skip to first unread message

zippers24

unread,
Aug 4, 2008, 4:55:38 PM8/4/08
to Django users
I've been going through the djangobook, the online version, and am on
page 84, I have done all 5 steps but when I go to http://127.0.0.1:8000/admin/.

I get:

Traceback (most recent call last):
File "C:\Python25\lib\site-packages\django\core\handlers\base.py" in
get_response
77. response = callback(request, *callback_args, **callback_kwargs)
File "C:\Python25\Lib\site-packages\django\contrib\admin\views
\decorators.py" in _checklogin
50. if request.user.is_authenticated() and request.user.is_staff:

AttributeError at /admin/
'WSGIRequest' object has no attribute 'user'

Does anyone know why this might be the case and how I can solve the
problem?

Scott Moonen

unread,
Aug 4, 2008, 6:11:28 PM8/4/08
to django...@googlegroups.com
Andrew,

You can find all the information you need here: http://www.djangoproject.com/documentation/authentication/#authentication-in-web-requests

See especially the part that refers to enabling the appropriate middleware.

  -- Scott

zippers24

unread,
Aug 4, 2008, 6:44:49 PM8/4/08
to Django users
Thanks Scott, but I already have all the middleware enabled and no
errors are returned when I run manage.py runserver.

Scott Moonen

unread,
Aug 4, 2008, 8:03:41 PM8/4/08
to django...@googlegroups.com
Aah, interesting, ok.

One thing that strikes me is the fact that it is reporting you're providing a WSGIRequest object as the request parameter, rather than an HttpRequest.

I'm not very familiar with how WSGI processing is handled, but it does seem rather strange to me that your views would be running in a context where they were passed a WSGIRequest instead of an HttpRequest.

I'm not sure I'll be much help resolving it as a result.  But I do think that the first step would be to see your urls.py; could you paste it into dpaste.com and reply with the link?  Maybe someone else will have some insight.

  -- Scott


On Mon, Aug 4, 2008 at 6:44 PM, zippers24 <AndrewK...@gmail.com> wrote:

Thanks Scott, but I already have all the middleware enabled and no
errors are returned when I run manage.py runserver.




Reply all
Reply to author
Forward
0 new messages