Could someone explain me please what I'm doing wrong? I'm trying to enable admin panel in Django 1.2. But the link http://mysite.com/admin raises 404 error, and the link http://mysite.com raises an error like this:
有人能解释一下我做错了什么吗?我正在尝试在Django 1.2中启用管理面板。但是链接http://sitemy.com/admin会产生404错误,链接http://mysite.com会产生如下错误:
TypeError at /
list objects are unhashable
Request Method: GET
Request URL: http://mysite/index.wsgi/
Django Version: 1.2.4
Exception Type: TypeError
Exception Value:
list objects are unhashable
Exception Location: /usr/local/lib/python2.5/re.py in _compile, line 230
Python Executable: /usr/local/bin/python
Python Version: 2.5.5
Python Path: ['/usr/local.20100210/lib/python2.5/site-packages', '/usr/local/lib/python2.5/site-packages/setuptools-0.6c11-py2.5.egg', '/usr/local/lib/python2.5/site-packages/Genshi-0.6-py2.5.egg', '/usr/local/lib/python2.5/site-packages/Babel-0.9.5-py2.5.egg', '/usr/local/lib/python2.5/site-packages/Pygments-1.4-py2.5.egg', '/usr/local/lib/python2.5/site-packages/pytz-2010o-py2.5.egg', '/usr/local/lib/python2.5/site-packages/Trac-0.12.1-py2.5.egg', '/usr/local/lib/python2.5/site-packages/IniAdmin-0.2-py2.5.egg', '/usr/local/lib/python2.5/site-packages/TracAccountManager-0.2.1dev-py2.5.egg', '/usr/local/lib/python2.5/site-packages/MySQL_python-1.2.3-py2.5-freebsd-8.2-RELEASE-amd64.egg', '/usr/local/lib/python25.zip', '/usr/local/lib/python2.5', '/usr/local/lib/python2.5/plat-freebsd8', '/usr/local/lib/python2.5/lib-tk', '/usr/local/lib/python2.5/lib-dynload', '/usr/local/lib/python2.5/site-packages', '/usr/local/lib/python2.5/site-packages/PIL', '/usr/local/lib/python2.5/site-packages', '/home/casf58/www/site2/cgi-bin/']
Server time: Tue, 11 Jun 2013 20:52:41 +0400
This is the empty test project which works fine on local machine. But it doesn't work at hosting. Of course, I uncommented all the necessary lines in urls.py and setiings.py and checked it several times. If I comment them back, the Django Welcome page is displayed. Still can't find a solution in google...
这是在本地机器上运行良好的空测试项目。但它在主机上不起作用。当然,我没有注释url中的所有必要行。py和setiings。py检查了几次。如果我对它们进行注释,将显示Django欢迎页面。仍然无法在谷歌中找到解决方案……
Python v.2.5. Project uses wsgi_mod.
Python v.2.5。项目使用wsgi_mod。
Changes in settings.py:
settings.py变化:
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
My urls.py:
我的urls . py:
from django.conf.urls.defaults import *
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Example:
# (r'^mysite/', include('mysite.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
r'^admin/', include(admin.site.urls)
)
1 个解决方案
#1
2
You need to enclose your url pattern in ()
需要将url模式包含在()中
(r'^admin/', include(admin.site.urls)),
Try this:
试试这个:
urlpatterns = patterns('',
# Example:
# (r'^mysite/', include('mysite.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)
#1
2
You need to enclose your url pattern in ()
需要将url模式包含在()中
(r'^admin/', include(admin.site.urls)),
Try this:
试试这个:
urlpatterns = patterns('',
# Example:
# (r'^mysite/', include('mysite.foo.urls')),
# Uncomment the admin/doc line below to enable admin documentation:
# (r'^admin/doc/', include('django.contrib.admindocs.urls')),
# Uncomment the next line to enable the admin:
(r'^admin/', include(admin.site.urls)),
)