管理网站:TemplateDoesNotExist at / admin / [英] Admin Site: TemplateDoesNotExist at /admin/

查看:330
本文介绍了管理网站:TemplateDoesNotExist at / admin /的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在遵循Django的官方教程2 ,但由于某种原因,无法创建管理站点,尽管按照所有步骤正确地理解我。

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.

这是我得到的错误:

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

我在取消注释以下行后发生错误(commente d):

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.

django.contrib.admin 在我的INSTALLED_APPS中,settings.py

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

推荐答案

由于它适用于其他人们的机器,并且由于您启用了应用程序目录加载器,所以在 INSTALLED_APPS 中启用了管理站点,这就是模板被发现所需要的(我的意思是,还有什么可以一个人吗?) - 我只能假设你的django安装有问题。

Since it works on other people's machines, and since you have the app directories loader enabled, admin site enabled in INSTALLED_APPS, and that's all it should take for templates to be discovered (I mean, what more can one do?) - I can only assume something is wrong with your django installation.

这将是一个很好的机会,开始使用virtualenvs和一个新的安装django来统治e出您的设置:

This would be a good chance to start using virtualenvs and a fresh install of django to rule out your settings:

启动终端,导航到您的项目目录(实际上不重要...)

Fire up a terminal, navigate to your project directory (doesn't actually matter...)

pip install virtualenv # if you don't have it.

virtualenv --no-site-packages env 
# this creates a virtual python environment that doesn't include system packages

source env/bin/activate
# this forces your bash session to use that environment

pip install django
# installs a fresh copy of django to your new environment

cd path_to_my_django_project    
# now go to your site directory

python manager.py runserver
# visit admin site.

这篇关于管理网站:TemplateDoesNotExist at / admin /的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆