2010-07-02 74 views
0

我想进入我的网站管理应用程序。 要求:http://mysite.ru/admin/ - 我得到一个错误:ImportError管理模块

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/

什么问题?

回答

3

你可能忘了取消注释在settings.py的线路之一:

例如:

Add "django.contrib.admin" to your INSTALLED_APPS setting. Run python manage.py syncdb. Since you have added a new application to INSTALLED_APPS, the database tables need to be updated.

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 
) 
+0

我忘了从行中删除引号:'(r'^ admin /',include(admin.site.urls))',你的回答可以帮助我ee这个错误。谢谢。 – Kalinin 2010-07-02 07:46:43