Updated docs adding usage in templates and rendered

This commit is contained in:
Corey Oordt 2011-09-04 19:57:58 -04:00
parent fdbb08431e
commit c676fc1c8d
17 changed files with 196 additions and 67 deletions

View file

@ -2,12 +2,29 @@
Using categories in templates
=============================
To use the template tags:::
Getting all items within a category
===================================
The :py:class:`Category` model automatically gets `reverse relationships <https://docs.djangoproject.com/en/1.3/topics/db/queries/#following-relationships-backward>`_ with all other models related to it.
This allows you access to the related objects from the template without altering any views. For example, if you only had ``Entry`` models related to :py:class:`Category`, your ``categories/category_detail.html`` template could look like
.. literalinclude:: usage_example_template.html
:language: django
:linenos:
If you have ``related_name`` parameters to the configuration (see :ref:`registering_models`), then you would use ``category.related_name.all`` instead of ``category.relatedmodel_set.all``\ .
Template Tags
=============
To use the template tags::
{% import category_tags %}
Filters
*******
``tree_info``
-------------
@ -41,4 +58,5 @@ comma-separated list of feature names. The valid feature names are:
Books -> []
Sci-fi -> [u'Books']
Dystopian Futures -> [u'Books', u'Sci-fi']
Dystopian Futures -> [u'Books', u'Sci-fi']

View file

@ -0,0 +1,28 @@
{% extends 'categories/base.html' %}
{% block content %}
<h1>{{ category }}</h1>
{% if category.parent %}
<h2>Go up to
<a href="{{ category.parent.get_absolute_url }}">
{{ category.parent }}
</a></h2>
{% endif %}
{% if category.description %}<p>{{ category.description }}</p>{% endif %}
{% if category.children.count %}
<h2>Subcategories</h2>
<ul>
{% for child in category.children.all %}
<li><a href="{{ child.get_absolute_url }}">{{ child }}</a></li>
{% endfor %}
</ul>
{% endif %}
<h2>Entries</h2>
{% if category.entries_set.all %}
{% for entry in category.entries_set.all %}
<p><a href="{{ entry.get_absolute_url }}">{{ entry.headline }}</a></p>
{% endfor %}
{% else %}
<p><em>No entries for {{ category }}</em></p>
{% endif %}
{% endblock %}

View file

@ -2,12 +2,29 @@
Using categories in templates
=============================
To use the template tags:::
Getting all items within a category
===================================
The :py:class:`Category` model automatically gets `reverse relationships <https://docs.djangoproject.com/en/1.3/topics/db/queries/#following-relationships-backward>`_ with all other models related to it.
This allows you access to the related objects from the template without altering any views. For example, if you only had ``Entry`` models related to :py:class:`Category`, your ``categories/category_detail.html`` template could look like
.. literalinclude:: usage_example_template.html
:language: django
:linenos:
If you have ``related_name`` parameters to the configuration (see :ref:`registering_models`), then you would use ``category.related_name.all`` instead of ``category.relatedmodel_set.all``\ .
Template Tags
=============
To use the template tags::
{% import category_tags %}
Filters
*******
``tree_info``
-------------
@ -41,4 +58,5 @@ comma-separated list of feature names. The valid feature names are:
Books -> []
Sci-fi -> [u'Books']
Dystopian Futures -> [u'Books', u'Sci-fi']
Dystopian Futures -> [u'Books', u'Sci-fi']

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Adding the fields to the database &mdash; Django Categories v0.8 documentation</title>
<title>Adding the fields to the database &mdash; Django Categories v0.8.2 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.8',
VERSION: '0.8.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,13 +21,13 @@
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.8 documentation" href="index.html" />
<link rel="top" title="Django Categories v0.8.2 documentation" href="index.html" />
<link rel="next" title="Reference" href="reference/index.html" />
<link rel="prev" title="Registering Models" href="registering_models.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.8 documentation</p>
<p>Django Categories v0.8.2 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Adding the fields to the database</h1></div>

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Index &mdash; Django Categories v0.8 documentation</title>
<title>Index &mdash; Django Categories v0.8.2 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.8',
VERSION: '0.8.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,11 +21,11 @@
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.8 documentation" href="index.html" />
<link rel="top" title="Django Categories v0.8.2 documentation" href="index.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.8 documentation</p>
<p>Django Categories v0.8.2 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Index</h1></div>

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Getting Started &mdash; Django Categories v0.8 documentation</title>
<title>Getting Started &mdash; Django Categories v0.8.2 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.8',
VERSION: '0.8.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,13 +21,13 @@
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.8 documentation" href="index.html" />
<link rel="top" title="Django Categories v0.8.2 documentation" href="index.html" />
<link rel="next" title="Using categories in templates" href="usage.html" />
<link rel="prev" title="Django Categories v 0.8" href="index.html" />
<link rel="prev" title="Django Categories v 0.8.2" href="index.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.8 documentation</p>
<p>Django Categories v0.8.2 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Getting Started</h1></div>
@ -36,7 +36,7 @@
<li id="page_buttons">
<div class="headerButton"><a href="genindex.html" title="General Index" accesskey="I">index</a></div>
<div class="headerButton"><a href="usage.html" title="Using categories in templates" accesskey="N">next</a></div>
<div class="headerButton"><a href="index.html" title="Django Categories v 0.8" accesskey="P">previous</a></div>
<div class="headerButton"><a href="index.html" title="Django Categories v 0.8.2" accesskey="P">previous</a></div>
</li>
</ul>
</div>

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Django Categories v 0.8 &mdash; Django Categories v0.8 documentation</title>
<title>Django Categories v 0.8.2 &mdash; Django Categories v0.8.2 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.8',
VERSION: '0.8.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,15 +21,15 @@
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.8 documentation" href="#" />
<link rel="top" title="Django Categories v0.8.2 documentation" href="#" />
<link rel="next" title="Getting Started" href="getting_started.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.8 documentation</p>
<p>Django Categories v0.8.2 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Django Categories v 0.8</h1></div>
<div id="title"><h1>Django Categories v 0.8.2</h1></div>
<ul id="headerButtons">
<li id="toc_button"><div class="headerButton"><a href="#">Table of Contents</a></div></li>
<li id="page_buttons">
@ -83,7 +83,7 @@
<div class="body">
<div class="section" id="django-categories-v-version">
<h1>Django Categories v 0.8<a class="headerlink" href="#django-categories-v-version" title="Permalink to this headline"></a></h1>
<h1>Django Categories v 0.8.2<a class="headerlink" href="#django-categories-v-version" title="Permalink to this headline"></a></h1>
<p>Contents:</p>
<div class="toctree-wrapper compound">
<ul>
@ -92,7 +92,8 @@
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="usage.html">Using categories in templates</a><ul>
<li class="toctree-l2"><a class="reference internal" href="usage.html#filters">Filters</a></li>
<li class="toctree-l2"><a class="reference internal" href="usage.html#getting-all-items-within-a-category">Getting all items within a category</a></li>
<li class="toctree-l2"><a class="reference internal" href="usage.html#template-tags">Template Tags</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="registering_models.html">Registering Models</a><ul>
@ -138,7 +139,7 @@
<div class="clearer"></div>
</div>
<div id="breadcrumbs">
Django Categories v 0.8
Django Categories v 0.8.2
</ul>
</div>
<script type="text/javascript" charset="utf-8" src="_static/toc.js"></script>

Binary file not shown.

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Reference &mdash; Django Categories v0.8 documentation</title>
<title>Reference &mdash; Django Categories v0.8.2 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.8',
VERSION: '0.8.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,13 +21,13 @@
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.8 documentation" href="../index.html" />
<link rel="top" title="Django Categories v0.8.2 documentation" href="../index.html" />
<link rel="next" title="Management Commands" href="management_commands.html" />
<link rel="prev" title="Adding the fields to the database" href="../adding_the_fields.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.8 documentation</p>
<p>Django Categories v0.8.2 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Reference</h1></div>

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Management Commands &mdash; Django Categories v0.8 documentation</title>
<title>Management Commands &mdash; Django Categories v0.8.2 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.8',
VERSION: '0.8.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,14 +21,14 @@
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.8 documentation" href="../index.html" />
<link rel="top" title="Django Categories v0.8.2 documentation" href="../index.html" />
<link rel="up" title="Reference" href="index.html" />
<link rel="next" title="Models" href="models.html" />
<link rel="prev" title="Reference" href="index.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.8 documentation</p>
<p>Django Categories v0.8.2 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Management Commands</h1></div>

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Models &mdash; Django Categories v0.8 documentation</title>
<title>Models &mdash; Django Categories v0.8.2 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.8',
VERSION: '0.8.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,14 +21,14 @@
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.8 documentation" href="../index.html" />
<link rel="top" title="Django Categories v0.8.2 documentation" href="../index.html" />
<link rel="up" title="Reference" href="index.html" />
<link rel="next" title="Settings" href="settings.html" />
<link rel="prev" title="Management Commands" href="management_commands.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.8 documentation</p>
<p>Django Categories v0.8.2 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Models</h1></div>

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Settings &mdash; Django Categories v0.8 documentation</title>
<title>Settings &mdash; Django Categories v0.8.2 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.8',
VERSION: '0.8.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,14 +21,14 @@
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.8 documentation" href="../index.html" />
<link rel="top" title="Django Categories v0.8.2 documentation" href="../index.html" />
<link rel="up" title="Reference" href="index.html" />
<link rel="next" title="Template Tags" href="templatetags.html" />
<link rel="prev" title="Models" href="models.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.8 documentation</p>
<p>Django Categories v0.8.2 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Settings</h1></div>

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Template Tags &mdash; Django Categories v0.8 documentation</title>
<title>Template Tags &mdash; Django Categories v0.8.2 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.8',
VERSION: '0.8.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,13 +21,13 @@
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.8 documentation" href="../index.html" />
<link rel="top" title="Django Categories v0.8.2 documentation" href="../index.html" />
<link rel="up" title="Reference" href="index.html" />
<link rel="prev" title="Settings" href="settings.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.8 documentation</p>
<p>Django Categories v0.8.2 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Template Tags</h1></div>

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registering Models &mdash; Django Categories v0.8 documentation</title>
<title>Registering Models &mdash; Django Categories v0.8.2 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.8',
VERSION: '0.8.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,13 +21,13 @@
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.8 documentation" href="index.html" />
<link rel="top" title="Django Categories v0.8.2 documentation" href="index.html" />
<link rel="next" title="Adding the fields to the database" href="adding_the_fields.html" />
<link rel="prev" title="Using categories in templates" href="usage.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.8 documentation</p>
<p>Django Categories v0.8.2 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Registering Models</h1></div>

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search &mdash; Django Categories v0.8 documentation</title>
<title>Search &mdash; Django Categories v0.8.2 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.8',
VERSION: '0.8.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -22,7 +22,7 @@
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<script type="text/javascript" src="_static/searchtools.js"></script>
<link rel="top" title="Django Categories v0.8 documentation" href="index.html" />
<link rel="top" title="Django Categories v0.8.2 documentation" href="index.html" />
<script type="text/javascript">
jQuery(function() { Search.loadIndex("searchindex.js"); });
</script>
@ -31,7 +31,7 @@
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.8 documentation</p>
<p>Django Categories v0.8.2 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Search</h1></div>

File diff suppressed because one or more lines are too long

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Using categories in templates &mdash; Django Categories v0.8 documentation</title>
<title>Using categories in templates &mdash; Django Categories v0.8.2 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.8',
VERSION: '0.8.2',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,13 +21,13 @@
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.8 documentation" href="index.html" />
<link rel="top" title="Django Categories v0.8.2 documentation" href="index.html" />
<link rel="next" title="Registering Models" href="registering_models.html" />
<link rel="prev" title="Getting Started" href="getting_started.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.8 documentation</p>
<p>Django Categories v0.8.2 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Using categories in templates</h1></div>
@ -47,7 +47,8 @@
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="getting_started.html">Getting Started</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="">Using categories in templates</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#filters">Filters</a></li>
<li class="toctree-l2"><a class="reference internal" href="#getting-all-items-within-a-category">Getting all items within a category</a></li>
<li class="toctree-l2"><a class="reference internal" href="#template-tags">Template Tags</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="registering_models.html">Registering Models</a></li>
@ -89,11 +90,74 @@
<div class="section" id="using-categories-in-templates">
<h1>Using categories in templates<a class="headerlink" href="#using-categories-in-templates" title="Permalink to this headline"></a></h1>
<p>To use the template tags::</p>
<div class="section" id="getting-all-items-within-a-category">
<h2>Getting all items within a category<a class="headerlink" href="#getting-all-items-within-a-category" title="Permalink to this headline"></a></h2>
<p>The <tt class="xref py py-class docutils literal"><span class="pre">Category</span></tt> model automatically gets <a class="reference external" href="https://docs.djangoproject.com/en/1.3/topics/db/queries/#following-relationships-backward">reverse relationships</a> with all other models related to it.</p>
<p>This allows you access to the related objects from the template without altering any views. For example, if you only had <tt class="docutils literal"><span class="pre">Entry</span></tt> models related to <tt class="xref py py-class docutils literal"><span class="pre">Category</span></tt>, your <tt class="docutils literal"><span class="pre">categories/category_detail.html</span></tt> template could look like</p>
<div class="highlight-django"><table class="highlighttable"><tr><td class="linenos"><div class="linenodiv"><pre> 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28</pre></div></td><td class="code"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">extends</span> <span class="s1">&#39;categories/base.html&#39;</span> <span class="cp">%}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">block</span> <span class="nv">content</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">&lt;h1&gt;</span><span class="cp">{{</span> <span class="nv">category</span> <span class="cp">}}</span><span class="x">&lt;/h1&gt;</span>
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">category.parent</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> &lt;h2&gt;Go up to </span>
<span class="x"> &lt;a href=&quot;</span><span class="cp">{{</span> <span class="nv">category.parent.get_absolute_url</span> <span class="cp">}}</span><span class="x">&quot;&gt;</span>
<span class="x"> </span><span class="cp">{{</span> <span class="nv">category.parent</span> <span class="cp">}}</span><span class="x"></span>
<span class="x"> &lt;/a&gt;&lt;/h2&gt;</span>
<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">category.description</span> <span class="cp">%}</span><span class="x">&lt;p&gt;</span><span class="cp">{{</span> <span class="nv">category.description</span> <span class="cp">}}</span><span class="x">&lt;/p&gt;</span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">category.children.count</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> &lt;h2&gt;Subcategories&lt;/h2&gt;</span>
<span class="x"> &lt;ul&gt;</span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">child</span> <span class="k">in</span> <span class="nv">category.children.all</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> &lt;li&gt;&lt;a href=&quot;</span><span class="cp">{{</span> <span class="nv">child.get_absolute_url</span> <span class="cp">}}</span><span class="x">&quot;&gt;</span><span class="cp">{{</span> <span class="nv">child</span> <span class="cp">}}</span><span class="x">&lt;/a&gt;&lt;/li&gt;</span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> &lt;/ul&gt;</span>
<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">&lt;h2&gt;Entries&lt;/h2&gt;</span>
<span class="cp">{%</span> <span class="k">if</span> <span class="nv">category.entries_set.all</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">for</span> <span class="nv">entry</span> <span class="k">in</span> <span class="nv">category.entries_set.all</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> &lt;p&gt;&lt;a href=&quot;</span><span class="cp">{{</span> <span class="nv">entry.get_absolute_url</span> <span class="cp">}}</span><span class="x">&quot;&gt;</span><span class="cp">{{</span> <span class="nv">entry.headline</span> <span class="cp">}}</span><span class="x">&lt;/a&gt;&lt;/p&gt;</span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endfor</span> <span class="cp">%}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> &lt;p&gt;&lt;em&gt;No entries for </span><span class="cp">{{</span> <span class="nv">category</span> <span class="cp">}}</span><span class="x">&lt;/em&gt;&lt;/p&gt;</span>
<span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">endblock</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</td></tr></table></div>
<p>If you have <tt class="docutils literal"><span class="pre">related_name</span></tt> parameters to the configuration (see <a class="reference internal" href="registering_models.html#registering-models"><em>Registering Models</em></a>), then you would use <tt class="docutils literal"><span class="pre">category.related_name.all</span></tt> instead of <tt class="docutils literal"><span class="pre">category.relatedmodel_set.all</span></tt>.</p>
</div>
<div class="section" id="template-tags">
<h2>Template Tags<a class="headerlink" href="#template-tags" title="Permalink to this headline"></a></h2>
<p>To use the template tags:</p>
<div class="highlight-python"><pre>{% import category_tags %}</pre>
</div>
<div class="section" id="filters">
<h2>Filters<a class="headerlink" href="#filters" title="Permalink to this headline"></a></h2>
<div class="section" id="tree-info">
<h3><tt class="docutils literal"><span class="pre">tree_info</span></tt><a class="headerlink" href="#tree-info" title="Permalink to this headline"></a></h3>
<p>Given a list of categories, iterates over the list, generating