0
我有几个应用程序的Django项目。为了与通用名称(如index
,menu
,...,page1
,page2
)更多然后其中一人我采用了这种架构能够使用模板:Django:如何简化从子目录中呈现模板的调用
app1/
templates/
app1/
page1.html
page2.html
app2/
templates/
app2/
page1.html
page2.html
和意见我用它这样的:
def myview(request): # in app1
context={'name':'John', 'surname':'Lennon'}
return render(request,"app1/page1.html",context)
或
def myview(request): # in app2
context={'tool':'hammer', 'size':'big'}
return render(request,"app2/page1.html",context)
它的工作原理,但我写的应用全称(app1/
,app2/
)(并且没有应用程序使用来自其他应用程序的模板或仅从模板/(项目本身除外))和应用程序名称实际上很长,如10-17个字符(不像app1
,app2
)
问题:有没有更好的办法,每个应用程序呈现不会默认为templates/
,而是分别为templates/app1/
,templates/app2/
等等?
感谢所有的建议