简体   繁体   中英

Django ImportError at /admin/

When I try to access to my Django admin site I got the following error:

ImportError at /admin/

No module named django.views

Request Method: GET Request URL: http://127.0.0.1:8000/admin/ Django Version: 1.4.1 Exception Type: ImportError Exception Value:

No module named django.views

Exception Location: /usr/local/lib/python2.7/dist-packages/django/utils/importlib.py in import_module, line 35 Python Executable: /usr/bin/python Python Version: 2.7.3

Here is my urls.py file:

from django.conf.urls import patterns, include, url

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

urlpatterns = patterns('',
    url(r'^$', include('home.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
)

When I comment the line url(r'^$', include('home.urls')) , the admin site works againg.

I can't figure out what my problem is. Can you help me?

You have an error in one of your own views somewhere else in the code, which is trying to import django.views . The admin site needs to import all views in order to reverse URLs properly, so is triggering the error even though it isn't in the admin code itself.

I m not sure if it quenches ya thirst for the right answer.. I tried replicating the issue and found that instead of using

include('home.urls')

if you replace it with something like

(admin.site.urls)

or you could also use

url(r'^{{project_name}}', '{{project_name}}.{{app_name}}.views.{{some html template file}}'),

then it works fine.Hope it at least helps you narrow down on point of impact.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM