2010-07-02 109 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