/(给定url)不存在模板 [英] template does not exist at /(given url)

查看:131
本文介绍了/(给定url)不存在模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它在本地主机上工作,但在生产中显示此错误:

It worked on localhost, but in production it is showing this error:

TemplateDoesNotExist at /tcapp/tcpage

app / urls.py

app/urls.py

from django.conf.urls import url 
from .import views

urlpatterns = [
    url(r'^tcapp/tcpage', views.tcpage, name='tcpage'),
    url(r'^tcapp/tcappretrive', views.tcappretrive, name='tcappretrive'),
    url(r'^tcapp/home',views.tcpage,name='tcpage'),
    url(r'^tcapp/work',views.work,name='work'),
    url(r'^tcapp/s&c',views.support,name='support'),
]

模板:


  • home.html

  • work.html

  • s& c.html

可能导致此错误消息?

推荐答案

这可能是这个原因 -

Here might be the reasons for this-


  1. 你的设置包括正确的模板目录?
    您可能需要在settings.py中检查TEMPLATE_DIR设置 -

  1. Does your settings includes the correct template directory ? You might need to check TEMPLATE_DIR settings in settings.py -

  TEMPLATES = [
                {
                  'BACKEND': 'django.template.backends.django.DjangoTemplates',
                  'DIRS': [
                      '/home/html/example.com',
                      '/home/html/default',
                     ],
                 },
               {
                'BACKEND': 'django.template.backends.jinja2.Jinja2',
                'DIRS': [
                        '/home/html/jinja2',
                        ],
                },
    ]

查看更多

此外,您可能需要使用os.path函数添加模板目录。

Also, you might need to add a template directory using os.path function .

让我知道,如果这样解决你的问题。

Let me know, if this solves your problem.

这篇关于/(给定url)不存在模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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