无法导入名称admin

时间:2012-11-19 12:04:43

标签: django django-models django-admin

我是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'      
 ...
 ...]

1 个答案:

答案 0 :(得分:3)

确保settings.py django.contrib.adminINSTALLED_APPS取消注释 urls.py。还要检查from django.contrib import admin admin.autodiscover()

中是否有这些行
{{1}}