1

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

1 回答 1

3

确保在你的settings.py你有django.contrib.admin未注释INSTALLED_APPS。并检查您的urls.py:

from django.contrib import admin
admin.autodiscover()
于 2012-11-19T12:24:46.993 回答