0

所以我是Django的新手,目前正尝试在我的应用中构建注册。我已经遵循这个guide。然而,我遇到了一个问题,即应用程序无法以某种方式找到该模板。TemplateDoesNotExist at/accounts/register/Error

Traceback: 

文件 “/usr/local/lib/python3.5/site-packages/django/core/handlers/exception.py” 在内 39.响应= get_response(请求)

文件 “/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py” 在_get_response 217.响应= self.process_exception_by_middleware(E,请求)

文件 “/usr/local/lib/python3.5/site-packages/django/core/handlers/base.py” 在_get_response 215响应= response.render()

文件 “/ USR/local/lib目录/ python3.5 /站点包/ Django的/模板/ response.py “ 在渲染 109 self.content = self.rendered_content

文件 ” 在/ usr/local/lib目录/ python3 .5/site-packages/django/template/response.py“ in rendered_content 84. template = self.resolve_template(self.template_name)

文件 “/usr/local/lib/python3.5/site-packages/django/template/response.py” 在resolve_template 66.返回select_template(模板,使用= self.using)

文件 “/usr/local/lib/python3.5/site-packages/django/template/loader.py” 在 select_template 53.加注TemplateDoesNotExist( ''。加入(template_name_list),链=链)

异常类型:TemplateDoesNotExist at/accounts/register/Exception Value:registration/registration_form.html

我已检查以确保我的URL已设置,并且所有内容都应按顺序排列。我花了过去2个小时寻找解决方案,没有任何工作。

最让我感动的是,在错误中,我可以看到它在哪里检查模板的确切位置,但我仍然看到该模板的实际路径旁边的以下内容。

(来源不存在)

请帮

+0

你确实有一个名为'registration/registration_form.html'的模板吗?该文件是否可以通过Web服务器wsgi进程读取?你如何在'settings.py'中指定你的模板目录? –

+0

是的,模板实际上在那里,它是可读的。我认为这个问题与我的模板目录有关,但作为我的新手,我不知道我做错了什么。这是我的'settings.py'代码如下。 'TEMPLATE_DIRS = [ os.path.join(BASE_DIR, '/帐号/注册/'), os.path.join(BASE_DIR, '项目/模板/'), ]' – Kerosive

回答

0

请检查您所定义TEMPLATES_DIRS正确

在Django中1。8以上:

TEMPLATES = [ 
    { 
     'DIRS': [ 
      # insert your TEMPLATE_DIRS here (absolute path) 
     ], 
    }, 
] 
+0

确保路径是绝对的 – brunoelottero

+0

我正在使用Django的注册,这是否仍然适用于使用这样的包? – Kerosive

+0

是的,对于你打算把模板修改为 – brunoelottero