As many people, I can't login to Django (Nonrel) admin interface, and the solution other users have given don't work in my situation. I'm running Python 2.7 and Google App Engine 1.6.0.
Let's see. I have this in my urls.py:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
(r'^$', 'django.views.generic.simple.direct_to_template', {'template': 'home.html'}),
url(r'^admin/', include(admin.site.urls)),
)
And this in settings.py
MIDDLEWARE_CLASSES = (
'mediagenerator.middleware.MediaMiddleware',
# This loads the index definitions, so it has to come first
'autoload.middleware.AutoloadMiddleware',
# Media middleware has to come first
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.contenttypes',
'django.contrib.auth',
'django.contrib.sessions',
'djangotoolbox',
'autoload',
'dbindexer',
'mediagenerator',
# djangoappengine should come last, so it can override a few manage.py commands
'djangoappengine',
)
I created a superuser after uncommenting 'django.contrib.admin' but it doesn't work. I created another superuser manually (via python manage.py createsuperuser), which doesn't work either. However, the weird part is that those superusers are available:
python manage.py shell
>>> from django.contrib.auth.models import User
>>> User.objects.all()
[<User: robert>, <User: john>]
>>> User.objects.all()[0].is_staff
True
>>> User.objects.all()[0].is_superuser
True
And yet, I can't login.
I don't know if it's related, but when a run python manage.py runserver, I get the following exception:
Exception happened during processing of request from ('127.0.0.1', 55568)
Traceback (most recent call last):
File "/usr/lib/python2.7/SocketServer.py", line 284, in _handle_request_noblock
self.process_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 310, in process_request
self.finish_request(request, client_address)
File "/usr/lib/python2.7/SocketServer.py", line 323, in finish_request
self.RequestHandlerClass(request, client_address, self)
File "/usr/local/google_appengine/google/appengine/tools/dev_appserver.py", line 2438, in __init__
BaseHTTPServer.BaseHTTPRequestHandler.__init__(self, *args, **kwargs)
File "/usr/lib/python2.7/SocketServer.py", line 641, in __init__
self.finish()
File "/usr/lib/python2.7/SocketServer.py", line 694, in finish
self.wfile.flush()
File "/usr/lib/python2.7/socket.py", line 303, in flush
self._sock.sendall(view[write_offset:write_offset+buffer_size])
error: [Errno 32] Broken pipe
Any suggestions?
By the way, I have created superusers without the server running, as David Poblador suggested in this question.
UPDATE: I tried to deploy (python manage.py deploy), but it happens exactly the same. I can't login with any superuser, although other than that, there are no errors.
UPDATE 2: I read a thread that suggested looking at /_ah/admin, but I'm not sure what to do there. I have auth_user, _AhAdminXsrfToken, django_session and a couple of 'tables' in the 'Entity Kind' field in Datastore Viewer. When I select auth_user, I get the following message "Datastore contains no entities of kind "auth_user" in the Empty namespace".
UPDATE 3: Alright, now I'm officially confused. I created another project using django-testapp adding only middleware_classes, autodiscover and django.contrib.admin to enable the admin interface. It loads the 'it works' page but I get that exception. It happens the same when I load localhost/admin. Again, after querying User.objects.all(), I get the correct list of superusers, but they don't work in the login page.
Thanks in advance.
Regards