Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
461 views
in Technique[技术] by (71.8m points)

python - Admin Site: TemplateDoesNotExist at /admin/

I'm following Django's official Tutorial 2 but for some reason cannot create an admin site despite following all the steps correctly to my understanding.

This is the error I get:

TemplateDoesNotExist at /admin/
admin/login.html
Request Method: GET
Request URL:    http://127.0.0.1:8000/admin/
Django Version: 1.3.1
Exception Type: TemplateDoesNotExist
Exception Value:    
admin/login.html
Exception Location: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/template/loader.py in find_template, line 138
Python Executable:  /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Python Version: 2.7.2
Python Path:    
['/Users/jcugley/Documents/Programming/Python/Django/mysite',
 '/Library/Python/2.7/site-packages/setuptools-0.6c11-py2.7.egg',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages',
 '/Library/Python/2.7/site-packages']
Server time:    Tue, 24 Jan 2012 18:40:03 -0600

The error occurs after I uncomment the following lines (commented):

### urls.py ###
from django.conf.urls.defaults import patterns, include, url

from django.contrib import admin # THIS LINE
admin.autodiscover() # THIS LINE

urlpatterns = patterns('',
    url(r'^admin/', include(admin.site.urls)), # THIS LINE
)

If I comment them again it gets rid of the error.

I do have django.contrib.admin in my INSTALLED_APPS in settings.py

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

I ran into the same problem, and I had to force pip to re-download django.

pip install -r requirements.txt --ignore-installed --force-reinstall --upgrade --no-cache-dir

Note: I know that the --no-cache-dir option is necessary, I'm not certain that the other options are all required.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...