2

有人可以解释一下我做错了什么吗?我正在尝试在 Django 1.2 中启用管理面板。但是链接http://mysite.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

这是在本地机器上运行良好的空测试项目。但它不适用于托管。当然,我取消了 urls.py 和 setiings.py 中所有必要行的注释并检查了几次。如果我回复它们,则会显示 Django 欢迎页面。谷歌还是找不到解决办法...

Python v.2.5。项目使用 wsgi_mod。

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',
) 

我的 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)
)
4

1 回答 1

2

您需要将您的 url 模式包含在()

 (r'^admin/', include(admin.site.urls)),

尝试这个:

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)),
)
于 2013-06-11T17:35:24.673 回答