Django for Designers: Difference between revisions

Content added Content deleted
imported>Paulproteus
imported>Paulproteus
(→‎Django templates 101: More tab=>space fixes)
Line 458: Line 458:
<source lang="python">
<source lang="python">
def tag(request, tag_name):
def tag(request, tag_name):
context = {
context = {
'tag': tag_name,
'tag': tag_name,
}
}
return render(request, 'tag.html', context)
return render(request, 'tag.html', context)
</source>
</source>


Line 504: Line 504:
<html>
<html>
<head>
<head>
<title>My bookmarking app</title>
<title>My bookmarking app</title>
</head>
</head>


<body>
<body>
<div id="header">
<div id="header">
<h1>My bookmarking app</h1>
<h1>My bookmarking app</h1>
</div>
</div>
<div id="content">
<div id="content">
<h2>{% block subheader %}{% endblock %}</h2>
<h2>{% block subheader %}{% endblock %}</h2>
{% block content %}
{% block content %}
Sample content -- you should never see this, unless an inheriting template fails to have any content block!
Sample content -- you should never see this, unless an inheriting template fails to have any content block!
{% endblock %}
{% endblock %}
</div>
</div>
<div id="footer">
<div id="footer">
Brought to you by PyCon US 2013
Brought to you by PyCon US 2013
</div>
</div>
</body>
</body>
</html>
</html>
Line 535: Line 535:
{% block content %}
{% block content %}
<ul>
<ul>
<li>Bookmark</li>
<li>Bookmark</li>
<li>Another bookmark</li>
<li>Another bookmark</li>
<li>A third bookmark</li>
<li>A third bookmark</li>
</ul>
</ul>
{% endblock %}
{% endblock %}