ImportError管理模块

时间:2010-07-02 07:36:33

标签: django django-admin

我想进入我网站的管理应用程序。 根据要求:http://mysite.ru/admin/ - 我收到错误:

ImportError at /admin/
No module named admin.site.urls
Request Method: GET
Request URL:    http://mysite.ru/admin/
Django Version: 1.2.1
Exception Type: ImportError
Exception Value:    
No module named admin.site.urls
Exception Location: /usr/lib/python2.4/site-packages/django/utils/importlib.py in import_module, line 35
Python Executable:  /usr/bin/python
Python Version: 2.4.3
Python Path:    ['/home/z/sites', '/usr/lib/python2.4/site-packages/setuptools-0.6c11-py2.4.egg', '/usr/lib/python2.4/site-packages/MySQL_python-1.2.3-py2.4-linux-i686.egg', '/usr/lib/python24.zip', '/usr/lib/python2.4', '/usr/lib/python2.4/plat-linux2', '/usr/lib/python2.4/lib-tk', '/usr/lib/python2.4/lib-dynload', '/usr/lib/python2.4/site-packages', '/usr/lib/python2.4/site-packages/Numeric', '/opt/CollabNet_Subversion/lib/svn-python', '/usr/lib/python2.4/site-packages/gtk-2.0']
Server time:    Fri, 2 Jul 2010 02:19:12 -0500

我按照此处所述连接的管理模块: http://docs.djangoproject.com/en/1.2/intro/tutorial02/

出了什么问题?

1 个答案:

答案 0 :(得分:3)

您可能忘记取消注释settings.py中的一行:

例如:

  

将“django.contrib.admin”添加到您的   INSTALLED_APPS设置。运行python   manage.py syncdb。既然你已经添加了   INSTALLED_APPS的新应用程序,   数据库表需要   更新。

INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.admin', #<----      !!!!! Uncomment
    'mysite.polls'
)

在你的urls.py中:(虽然看起来你已经完成了这一步)

# Uncomment the next two lines to enable the admin:
from django.contrib import admin #<----                     !!!!! Uncomment
admin.autodiscover() #<----                                 !!!!! Uncomment

urlpatterns = patterns('',
    # Example:
    # (r'^mysite/', include('mysite.foo.urls')),

    # Uncomment the admin/doc line below and add 'django.contrib.admindocs'
    # to INSTALLED_APPS 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)), #<----          !!!!! Uncomment
)