我是Django的新人。我正在尝试创建基本的管理面板。当我更改urls.py文件并将url(r' ^ admin /',include(admin.site.urls))放入模式中时,它会出现错误:
Request Method: GET return
Request URL: http://127.0.0.1:8000/
Django Version: 1.4
Exception Type: ImportError
Exception Value:cannot import name admin
Exception Location:/home/ulascan/Desktop/projects/purple/purple/urls.py in <module>, line 1
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path:
['/home/ulascan/Desktop/projects/purple',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2'
...
...]
答案 0 :(得分:3)
确保settings.py
django.contrib.admin
中INSTALLED_APPS
,取消注释 urls.py
。还要检查from django.contrib import admin
admin.autodiscover()
:
{{1}}