Admin pages not found
|Reported by:||Owned by:||nobody|
|Has patch:||no||Needs documentation:||no|
|Needs tests:||no||Patch needs improvement:||no|
I'm running into an issue (I think) with the development version of Django. I followed these instructions to install the Django development version, running Ubuntu 10.10, Apache 2.2.16, and libapache2-mod-wsgi 3.2-2 (as output by dpkg -l | grep wsgi).
As I'm going through the tutorial, everything worked fine until I reached the admin page in part 2. Initially, testing using
python manage.py runserver
would show the styles, while testing using Apache would not. I resolved that by adding:
Alias /static/admin/ /home/wayne/programming/build/django-trunk/django/contrib/admin/media/
After reloading the page a few times, the Polls page showed up. However, when I clicked on it I was presented with a 404 error. After going back in and reloading a few times, it finally worked. I went on to adding the Choices part, and during this time the Polls and Choices would only intermittently appear in the Admin list. And randomly when I would do an action, I would be met with something of this nature:
Page not found (404) Request Method: GET Request URL: http://localhost/admin/polls/choice/add/ Using the URLconf defined in waynesdomain.urls, Django tried these URL patterns, in this order: ^admin/ ^$ [name='index'] ^admin/ ^logout/$ [name='logout'] ^admin/ ^password_change/$ [name='password_change'] ^admin/ ^password_change/done/$ [name='password_change_done'] ^admin/ ^jsi18n/$ [name='jsi18n'] ^admin/ ^r/(?P<content_type_id>\d+)/(?P<object_id>.+)/$ ^admin/ ^(?P<app_label>\w+)/$ [name='app_list'] ^admin/ ^auth/user/ ^admin/ ^sites/site/ ^admin/ ^auth/group/ ^admin/ ^polls/poll/ The current URL, admin/polls/choice/add/, didn't match any of these. You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
This type of error is intermittent - Sometimes I can add choices perfectly fine, other times it won't let me add anything, at least when using Apache. If I use the Django testing server, I haven't had a single problem.
I'm not sure if this is an issue with my paths, but I don't think it's an Apache or mod_wsgi error, as using the version of Django in the Ubuntu repositories worked just fine.
The only real clue I have is that the errors seem to coincide with this message in /var/log/apache2/error.log
[Sat May 21 19:53:52 2011] [error] Exception KeyError: KeyError(-1216001392,) in <module 'threading' from '/usr/lib/python2.6/threading.pyc'> ignored
from polls.models import Poll, Choice from django.contrib import admin class PollAdmin(admin.ModelAdmin): fields = ['pub_date', 'question'] admin.site.register(Poll, PollAdmin) admin.site.register(Choice)
from django.conf.urls.defaults import patterns, include, url # Uncomment the next two lines to enable the admin: from django.contrib import admin admin.autodiscover() urlpatterns = patterns('', # Examples: # url(r'^$', 'waynesdomain.views.home', name='home'), # url(r'^waynesdomain/', include('waynesdomain.foo.urls')), # Uncomment the admin/doc line below to enable admin documentation: # url(r'^admin/doc/', include('django.contrib.admindocs.urls')), # Uncomment the next line to enable the admin: url(r'^admin/', include(admin.site.urls)), )