Django version of Zend's Layouts?
Doe开发者_如何学编程s Django have something like Zend's Layouts? I use layouts in Zend a lot to provide the common elements of a website (I often call it the 'frame' around the content), e.g. the header, footer, etc. Then I render a view inside the layout to provide the custom content.
Is such a thing possible in Django?
I've never used Zend, but from the sounds of what you are asking, you can use Django's templates.
Basically you are going to create a base.html template that has your 'frame' and you can have other templates inherit from that.
Your base.html will look like
<html>
<head>
<title>{% block title %}title{% endblock %}</title>
</head>
{% block content %}{% endblock %}<br>
</body>
</html>
You can than have your 'child' templates look like:
{% extends "../templates/app/base.html"%}
{% block content %}
words on my page
{% endblock %}
精彩评论