【发布时间】:2015-12-15 16:18:00
【问题描述】:
我正在尝试从另一个应用程序渲染到模板,但不确定如何导入或是否应该使用模板导入?
结构是
project->
main app->
templates->
pages->
home.html
account ->
current app->
views.py
我的 views.py 文件位于当前应用程序中,并试图访问主应用程序中的模板(在 pages 子文件夹中)。
我将如何渲染它:
def temp_view(request):
....
return render(request, "home.html",context)
【问题讨论】:
-
什么不起作用?很可能应该是
pages/home.html -
你可以使用
"pages/home.html",Django 会处理它