Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
django base.html模板,注意结构和层次,是个设计问题
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<title>{% block title %}标题{% endblock %}</title>
<meta name="viewport" content="width=device-width, initial-scale=1.0" ><!--responsive响应式-->
<link rel="stylesheet" href="/static/css/bootstrap2.3.1.min.css">
<!--自己的css放到这里-->
<link rel="stylesheet" href="/static/css/bootstrap-responsive.min.css"><!--responsive响应式-->
<script src="/static/js/jquery-1.8.2.min.js"></script><!--jquery-->
<script src="/static/js/bootstrap.min.js"></script><!--bootstrap-->
<!-- 静态文件引用 成功-->
{% block extra_head %}
{% comment %}
其他的全局Javascript, CSS, 以及别的应该放在文档头的信息.
{% endcomment %}
{% endblock %}
{% block app_page_head %}
{% comment %}
单个应用里的,可定制化,为了灵活
{% endcomment %}
{% endblock %}
</head>
<body>
{% block content %}
主体内容
{% endblock %}
{% block footer %}
页脚
{% endblock %}
{% block js %}
<!--这里插入具体页面引用的js库,或者js代码,要写完整<script>-->
{% endblock %}
<script>
$(function(){ //这里插入具体界面的on_ready代码,不用完整,<script>,on ready已经有了>
{% block on_ready %}
{% endblock %}
});
</script>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.