【问题标题】:can find the problem to solve Template doesn't working?能找到解决Template does\n't working的问题吗?
【发布时间】:2022-11-30 14:56:52
【问题描述】:
from django.shortcuts import render


# Create your views here.
def home(request):
    return render(request, 'dashboard/home.html')
from django.urls import path
from . import views

urlpatterns = [
    path('', views.home),

]

请帮我解决问题

在 template_DIRs 中添加路径

【问题讨论】:

  • 确切的错误是什么?

标签: python django django-views django-templates


【解决方案1】:

在你的settings.py 添加这个变量:

import os

TEMPLATE_DIR = os.path.join(BASE_DIR, "templates")

TEMPLATE_DIRS中添加TEMPLATE_DIR。 然后,在项目的根目录下创建一个名为templates 的文件夹。或者在您的应用程序目录中创建一个名为templates 的文件夹。在 templates 文件夹中放置您的 dashboard 文件夹。

【讨论】:

    猜你喜欢
    • 2023-01-08
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-11-24
    • 1970-01-01
    • 2022-11-17
    • 2016-05-21
    • 2020-09-03
    相关资源
    最近更新 更多