Django 我的templates目录是否需要一个_uinit__u;.py文件?
我正在使用Django和Python 3.7。我的项目层次结构中有以下内容Django 我的templates目录是否需要一个_uinit__u;.py文件?,django,python-3.x,Django,Python 3.x,我正在使用Django和Python 3.7。我的项目层次结构中有以下内容 + project + web + views tax_calculator.py + forms __init__.py tax_calculator_form.py + templates tax_calculator.html 我的视图文件“tax_calcula
+ project
+ web
+ views
tax_calculator.py
+ forms
__init__.py
tax_calculator_form.py
+ templates
tax_calculator.html
我的视图文件“tax_calculator.py”正在尝试使用
# Basic function that serves the default page
def get(request):
tax_calculator_form = TaxCalculatorForm()
return render(request, "web/templates/tax_calculator.html", {'form': tax_calculator_form})
但我得到了错误
TemplateDoesNotExist at /calculate_taxes
当我访问我的URL时,它在我的视图中抱怨这一行
return render(request, "web/templates/tax_calculator.html", {'form': tax_calculator_form})
我觉得这条路是正确的。为什么我的URL找不到我的模板路径?在回答您的问题标题时,否。
\uuuuu init\uuuuuuuuuupy
是用于python模块的,而不是用于资产目录
根据您指定的路径,您不需要相对路径,
“tax\u calculator.html”
就足够了。在回答您的问题标题时,否。\uuu init\uuuuuuuuuuuuuuuupy
用于python模块,而不是资产目录
根据您如何指定,您不需要相对路径,
“tax\u calculator.html”
应该足够了。啊,它被设置为“模板”,而不是实际路径--“web/templates”。Thx@Dave-不用担心,你可能会想看到我为设置添加的链接,特别是APP_DIRS
optionAh,它被设置为“模板”,而不是实际路径--“web/templates”。Thx@Dave-不用担心,您可能希望看到我为设置添加的链接,特别是APP\u DIRS
选项