-2
我想将一个基于PHP的网站迁移到Django作为框架的Python。你如何在Django模板中嵌套?
但是,我遇到了模板的实际问题。我似乎无法理解他们在结构方面的工作方式。
通过这个,我指的是“嵌套”,使用不同的页面来构建模板,就像在PHP中完成的一样。举个例子如下 -
的index.php -
<html>
<head>
<title>Home | Sequence Control Panel</title>
<?php require_once "head.php"; ?>
</head>
<body>
<!-- Header -->
<?php require_once "nav.php"; ?>
<p>Hello World</p>
<!-- Footer -->
<?php require_once "footer.php"; ?>
</body>
</html>
footer.php -
<footer id="footer">
<ul class="icons">
<li><a href="#" class="icon fa-twitter"><span class="label">Twitter</span></a></li>
<li><a href="#" class="icon fa-facebook"><span class="label">Facebook</span></a></li>
<li><a href="#" class="icon fa-instagram"><span class="label">Instagram</span></a></li>
<li><a href="#" class="icon fa-dribbble"><span class="label">Dribbble</span></a></li>
<li><a data-toggle="modal" data-target="#myModal" class="icon fa-envelope-o"><span class="label">Email</span></a></li>
</ul>
<ul class="copyright">
<li>© <?= date('Y'); ?> Sequence CP</li><li><a href="terms-and-conditions">Terms & Conditions</a></li>
</ul>
本质上讲,我分裂页脚,头和导航三不同的页面并链接回它们。
怎样一个链接多个页面的内容,一个页面正如我上面的index.php和footer.php用<?php require_once "footer.php"; ?>
我知道,我可以用做 -
{% block content %}
<p>Hello World</p>
{% endblock content %}
但我只能在我的模板中执行一次。我似乎无法多次使用block content
。
如何嵌套多页的内容而不仅仅是一个?
PS:我是新来的Django
[如何在网站中加入(嵌套)django应用程序]的可能重复(http://stackoverflow.com/questions/21782572/how-to-joinnest-django-apps-in-site) –