Python Django 1.7更改了模板名称now TemplateDoesNotExist错误
因此,我将注册模板的名称从user_form.html更改为register.html。我还在urls.py文件中对其进行了更改,以反映新名称,但是,当我尝试转到注册页面时,我得到以下信息:Python Django 1.7更改了模板名称now TemplateDoesNotExist错误,python,html,django,templates,django-templates,Python,Html,Django,Templates,Django Templates,因此,我将注册模板的名称从user_form.html更改为register.html。我还在urls.py文件中对其进行了更改,以反映新名称,但是,当我尝试转到注册页面时,我得到以下信息: Exception Type: TemplateDoesNotExist Exception Value:web/user_form.html Template-loader postmortem Django tried loading these templates, in this order
Exception Type: TemplateDoesNotExist
Exception Value:web/user_form.html
Template-loader postmortem
Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
../swl/root/lib/pythpy2.7.egg/django/contrib/admin/templates/web/user_form.html (File does not exist)
../django/contrib/auth/templates/web/user_form.html (File does not exist)
../templates/web/user_form.html (File does not exist)
..tastypie/templates/web/user_form.html (File does not exist)
../bootstrap3/templates/web/user_form.html (File does not exist)
../web/templates/web/user_form.html (File does not exist)
为什么模板加载器仍在寻找旧文件名
编辑:这是我的注册url:
url(r'register/?$”,
UserCreate.as_view(),
{
“模板名称”:“accounts/register.html”
},
name='register'),
尝试将所有文件中的所有user\u form.html
替换为registation.html
。您可以使用文本编辑器或IDE的Find/replace in files
功能(或类似功能)
将url
更改为:
url(r'register/?$',
UserCreate.as_view(template_name='accounts/register.html'),
name = 'register')
当没有显式声明名称时,基于类的视图将尝试使用默认模板名称。(CreateView使用(appname)/(model)\u form.html)您可以选择:
/etc/init.d/apache2 restart
显示您在URL.py中更改的内容。谢谢@valdimir,我这样做了,但仍然得到错误。@user5852854尝试更改
UserCreate.as_view(…)
。我会将其更改为什么?先生,您太棒了-谢谢!
/etc/init.d/apache2 restart