2024-10-16 20:43:23 发布
网友
我已经尝试了所有方法,并且在view.py中路径是正确的,但是在django中获取模板并没有发现错误 我的观点
def starting_page(request): return render(request,"tractor/index.html") def posts(request): return render(request,"tractor/all-post.html")
我还添加了ss的错误和我的目录
我们可以尝试遵循docs中设置的结构,因此尝试将文件移动到应用程序中的以下位置(假设my_proj是django项目的名称tractor是应用程序的名称):
my_proj
tractor
my_proj/tractor/templates/tractor/index.html my_proj/tractor/templates/tractor/all-post.html
要确保找到这些html文件,请验证settings.py是否按照文档中的说明正确配置了该文件
settings.py
First, make sure your template settings are checking inside app directories:TEMPLATES = [ { ..., 'APP_DIRS': True, ... }, ]
First, make sure your template settings are checking inside app directories:
TEMPLATES = [ { ..., 'APP_DIRS': True, ... }, ]
或者如果您的文件在项目中而不在应用程序中:
TEMPLATES = [ { ... 'DIRS': [BASE_DIR / 'templates'], ... }, ]
我们可以尝试遵循docs中设置的结构,因此尝试将文件移动到应用程序中的以下位置(假设
my_proj
是django项目的名称tractor
是应用程序的名称):要确保找到这些html文件,请验证
settings.py
是否按照文档中的说明正确配置了该文件或者如果您的文件在项目中而不在应用程序中:
相关问题 更多 >
编程相关推荐