繁体   English   中英

我无法在 django 中使用渲染查看我的模板

[英]I can't view my template with render in django

我的模板名为 hello.html

<h1>Hello World</h1>

我的意见.py

   from django.shortcuts import render
   from django.http import HttpResponse

   def say_hello(request):
       return render(request,'hello.html')

此外,如果我尝试 return HttpResponse('Hello World') 它正在工作。 但是兰德不起作用。

确保您在如下设置中指定了templates

   

     TEMPLATES = [
            {
                "BACKEND": "django.template.backends.django.DjangoTemplates",
                "DIRS": [BASE_DIR / 'templates'],
                "APP_DIRS": True,

并确保您在设置的INSTALLED_APPS中也提到了您的应用程序,并将所有 html 文件保存在模板文件夹中

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM