Django项目基础模板 [英] Django project base template
本文介绍了Django项目基础模板的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我可以为我的项目创建所有应用程序可以绘制的基本模板吗?还是为每个应用程序创建基准模板?如果我想要他们一样,我只是复制他们?
Can I create a base template for my project which all apps can draw from? Or do I have to create a base template for each app? And if I wanted them to be the same I'd just copy them?
推荐答案
当然可以。一个base.html的简单例子
Sure you can. A quick example of a base.html
<!DOCTYPE html>
<html>
<head>
<title>My Project</title>
</head>
<body>
{% block content %}{% endblock content %}
</body>
</html>
说你有一个名为myapp的应用程序,带有一个view.html页面,
And say you have a app called myapp with a view.html page,
{% extends "base.html" %}
{% block content %}
<h2>Content for My App</h2>
<p>Stuff etc etc.</p>
{% endblock content %}
花一些时间到阅读文档了解更多信息
Take some time to read the docs for more information
这篇关于Django项目基础模板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文