【发布时间】:2015-07-18 21:46:05
【问题描述】:
我知道我搞砸了,因为谷歌没有返回任何结果。我对计算机不太了解,但0x00000blah 看起来像是一些内存地址。刷新几次后,这个数字就会改变。
环境 Django 1.8、Python 3.4、chrome、Win7
预期行为
我想去../accounts/login/ 在我的网址中也称为url(r'^login/$', 'django.contrib.auth.views.login', name='loginHandle') 输入用户名、密码,如果它已注册,它会重定向到../accounts/profile,它应该呈现模板profile.html,它会说类似Hello {{ username }} ! .相反,我得到了这个错误
TemplateDoesNotExist 位于 /accounts/profile/
django.template.backends.django.Template 对象位于 0x0000000004D0E400
views.py
def profile(request):
profileTemplate = loader.get_template('registration/profile.html')
return render(request, profileTemplate, {
'Kitty': 10,
})
追溯
Using loader django.template.loaders.filesystem.Loader:
D:\users\kitty\python\firstdjangosite\templates\<django.template.backends.django.Template object at 0x0000000004D0E400> (File does not exist)
Using loader django.template.loaders.app_directories.Loader:
D:\Users\kitty\Python\lib\site-packages\django\contrib\admin\templates\<django.template.backends.django.Template object at 0x0000000004D0E400> (File does not exist)
D:\Users\kitty\Python\lib\site-packages\django\contrib\auth\templates\<django.template.backends.django.Template object at 0x0000000004D0E400> (File does not exist)
D:\users\kitty\python\firstdjangosite\polls\templates\<django.template.backends.django.Template object at 0x0000000004D0E400> (File does not exist)
D:\users\kitty\python\firstdjangosite\login\templates\<django.template.backends.django.Template object at 0x0000000004D0E400> (File does not exist)
D:\users\kitty\python\firstdjangosite\accounts\templates\<django.template.backends.django.Template object at 0x0000000004D0E400> (File does not exist)
路径详情
D:\Users\Kitty\Python\FirstDjangoSite\accounts\templates>dir /s /b /o:gn
accounts
registration
accounts\index.html
accounts\invalid.html
accounts\loggedin.html
accounts\logout.html
registration\login.html
registration\profile.html
我之前做过加载器和渲染,它们工作正常。例如,如果我将 profileTemplate 更改为不存在的“registration/helloworld.html”,它会显示
TemplateDoesNotExist 位于 /accounts/profile/
注册/helloworld.html
感谢您的宝贵时间,请帮助我感到困惑
【问题讨论】: