Update to template tags to include ways to retrieve an object from a model other than Category.

This commit is contained in:
Corey Oordt 2012-07-11 07:05:47 -04:00
parent 2a501a39a2
commit fa470df0a7
29 changed files with 1132 additions and 671 deletions

View file

@ -1,5 +1,3 @@
{% for item in category.get_ancestors %}
<a href="{{ item.get_absolute_url }}">{{ item.name }}</a>
{{ separator }}
{% endfor %}
{{ category.name }}
{% spaceless %}{% for item in category.get_ancestors %}
<a href="{{ item.get_absolute_url }}">{{ item.name }}</a>{{ separator }}{% endfor %}{{ category.name }}
{% endspaceless %}

View file

@ -1,4 +1,4 @@
{% load category_tags %}
{% load category_tags %}{% spaceless %}
<ul><li><a href="{% url categories_tree_list %}">Top</a>
{% for node,structure in path|tree_info %}
{% if structure.new_level %}<ul><li>
@ -8,4 +8,4 @@
{% else %}<a href="{{ node.get_absolute_url }}">{{ node.name }}</a>
{% endifequal %}
{% for level in structure.closed_levels %}</li></ul>{% endfor %}
{% endfor %}</li></ul>
{% endfor %}</li></ul>{% endspaceless %}

View file

@ -1,35 +1,61 @@
from django import template
from django.template import Library, Node, TemplateSyntaxError, \
Variable, resolve_variable, VariableDoesNotExist, Context
from django.db.models import get_model
from django.template import (Node, TemplateSyntaxError, Variable,
VariableDoesNotExist)
from categories.base import CategoryBase
from categories.models import Category
from mptt.utils import drilldown_tree_for_node
from mptt.templatetags.mptt_tags import tree_path, tree_info
from mptt.templatetags.mptt_tags import (tree_path, tree_info, recursetree,
full_tree_for_model)
register = template.Library()
register.filter("category_path", tree_path)
register.filter(tree_info)
register.tag(recursetree)
register.tag("full_tree_for_category", full_tree_for_model)
def get_category(category_string):
def resolve(var, context):
try:
return var.resolve(context)
except VariableDoesNotExist:
try:
return var.var
except AttributeError:
return var
def get_cat_model(model):
"""
Return a class from a string or class
"""
try:
if isinstance(model, basestring):
model_class = get_model(*model.split("."))
elif issubclass(model, CategoryBase):
model_class = model
if model_class is None:
raise TypeError
except TypeError:
raise TemplateSyntaxError("Unknown model submitted: %s" % model)
return model_class
def get_category(category_string, model=Category):
"""
Convert a string, including a path, and return the Category object
"""
if category_string.startswith('"') and category_string.endswith('"'):
category = category_string[1:-1]
else:
category = category_string
if category.startswith('/'):
category = category[1:]
if category.endswith('/'):
category = category[:-1]
model_class = get_cat_model(model)
category = category_string.strip("'\"")
category = category.strip('/')
cat_list = category.split('/')
if len(cat_list) == 0:
return None
try:
categories = Category.objects.filter(name = cat_list[-1], level=len(cat_list)-1)
categories = model_class.objects.filter(name=cat_list[-1],
level=len(cat_list) - 1)
if len(cat_list) == 1 and len(categories) > 1:
return None
# If there is only one, use it. If there is more than one, check
@ -40,30 +66,32 @@ def get_category(category_string):
for item in categories:
if item.parent.name == cat_list[-2]:
return item
except Category.DoesNotExist:
except model_class.DoesNotExist:
return None
class CategoryDrillDownNode(template.Node):
def __init__(self, category, varname):
def __init__(self, category, varname, model):
self.category = template.Variable(category)
self.varname = varname
self.model = model
def render(self, context):
category = resolve(self.category, context)
if isinstance(category, CategoryBase):
cat = category
else:
cat = get_category(category, self.model)
try:
category = self.category.resolve(context)
except template.VariableDoesNotExist:
category = self.category.var
try:
if category is not None:
context[self.varname] = drilldown_tree_for_node(category)
if cat is not None:
context[self.varname] = drilldown_tree_for_node(cat)
else:
context[self.varname] = []
except Category.DoesNotExist:
except:
context[self.varname] = []
return ''
@register.tag
def get_category_drilldown(parser, token):
"""
@ -72,11 +100,11 @@ def get_category_drilldown(parser, token):
Syntax::
{% get_category_drilldown "category name" as varname %}
{% get_category_drilldown "category name" [using "app.Model"] as varname %}
Example::
{% get_category_drilldown "/Grandparent/Parent" as family %}
{% get_category_drilldown "/Grandparent/Parent" [using "app.Model"] as family %}
or ::
@ -86,30 +114,44 @@ def get_category_drilldown(parser, token):
Grandparent, Parent, Child 1, Child 2, Child n
"""
bits = token.contents.split()
bits = token.split_contents()
error_str = '%(tagname)s tag should be in the format {%% %(tagname)s ' \
'"category name" as varname %%}.'
if len(bits) != 4 or bits[2] != 'as':
raise template.TemplateSyntaxError, error_str % {'tagname': bits[0]}
'"category name" [using "app.Model"] as varname %%} or ' \
'{%% %(tagname)s category_obj as varname %%}.'
if len(bits) == 4:
if bits[2] != 'as':
raise template.TemplateSyntaxError, error_str % {'tagname': bits[0]}
if bits[2] == 'as':
varname = bits[3].strip("'\"")
model = "categories.category"
if len(bits) == 6:
if bits[2] not in ('using', 'as') or bits[4] not in ('using', 'as'):
raise template.TemplateSyntaxError, error_str % {'tagname': bits[0]}
if bits[2] == 'as':
varname = bits[3].strip("'\"")
model = bits[5].strip("'\"")
if bits[2] == 'using':
varname = bits[5].strip("'\"")
model = bits[3].strip("'\"")
category = bits[1]
varname = bits[3]
return CategoryDrillDownNode(category, varname)
return CategoryDrillDownNode(category, varname, model)
@register.inclusion_tag('categories/breadcrumbs.html')
def breadcrumbs(category,separator="/"):
def breadcrumbs(category_string, separator=' > ', using='categories.category'):
"""
{% breadcrumbs category separator="::" using="categories.category" %}
Render breadcrumbs, using the ``categories/breadcrumbs.html`` template,
using the optional ``separator`` argument.
"""
if isinstance(category, CategoryBase):
cat = category
else:
cat = get_category(category)
cat = get_category(category_string, using)
return {'category': cat, 'separator': separator}
@register.inclusion_tag('categories/ul_tree.html')
def display_drilldown_as_ul(category):
def display_drilldown_as_ul(category, using='categories.Category'):
"""
Render the category with ancestors and children using the
``categories/ul_tree.html`` template.
@ -142,15 +184,12 @@ def display_drilldown_as_ul(category):
</li>
</ul>
"""
if isinstance(category, CategoryBase):
cat = category
else:
cat = get_category(category)
cat = get_category(category, using)
return {'category': cat, 'path': drilldown_tree_for_node(cat) or []}
@register.inclusion_tag('categories/ul_tree.html')
def display_path_as_ul(category):
def display_path_as_ul(category, using='categories.Category'):
"""
Render the category with ancestors, but no children using the
``categories/ul_tree.html`` template.
@ -180,14 +219,18 @@ def display_path_as_ul(category):
return {'category': cat, 'path': cat.get_ancestors() or []}
class TopLevelCategoriesNode(template.Node):
def __init__(self, varname):
def __init__(self, varname, model):
self.varname = varname
self.model = model
def render(self, context):
context[self.varname] = Category.objects.filter(parent=None).order_by('name')
model = get_cat_model(self.model)
context[self.varname] = model.objects.filter(parent=None).order_by('name')
return ''
@register.tag
def get_top_level_categories(parser, token):
"""
@ -195,31 +238,31 @@ def get_top_level_categories(parser, token):
Syntax::
{% get_top_level_categories as categories %}
{% get_top_level_categories [using "app.Model"] as categories %}
Returns an list of categories [<category>, <category>, <category, ...]
"""
bits = token.contents.split()
if len(bits) != 3:
raise template.TemplateSyntaxError(
"Usage: {%% %s as <variable> %%}" % bits[0]
)
if bits[1] != 'as':
raise template.TemplateSyntaxError(
"Usage: {%% %s as <variable> %%}" % bits[0]
)
return TopLevelCategoriesNode(bits[2])
bits = token.split_contents()
usage = 'Usage: {%% %s [using "app.Model"] as <variable> %%}' % bits[0]
if len(bits) == 3:
if bits[1] != 'as':
raise template.TemplateSyntaxError(usage)
varname = bits[2]
model = "categories.category"
elif len(bits) == 5:
if bits[1] not in ('as', 'using') and bits[3] not in ('as', 'using'):
raise template.TemplateSyntaxError(usage)
if bits[1] == 'using':
model = bits[2].strip("'\"")
varname = bits[4].strip("'\"")
else:
model = bits[4].strip("'\"")
varname = bits[2].strip("'\"")
def resolve(var, context):
try:
return var.resolve(context)
except VariableDoesNotExist:
try:
return var.var
except AttributeError:
return var
return TopLevelCategoriesNode(varname, model)
def get_latest_objects_by_category(category, app_label, model_name, set_name,
def get_latest_objects_by_category(category, app_label, model_name, set_name,
date_field='pub_date', num=15):
m = get_model(app_label, model_name)
if not isinstance(category, CategoryBase):
@ -229,13 +272,16 @@ def get_latest_objects_by_category(category, app_label, model_name, set_name,
for cat in list(children) + [category]:
if hasattr(cat, '%s_set' % set_name):
ids.extend([x.pk for x in getattr(cat, '%s_set' % set_name).all()[:num]])
return m.objects.filter(pk__in=ids).order_by('-%s' % date_field)[:num]
class LatestObjectsNode(Node):
def __init__(self, var_name, category, app_label, model_name, set_name,
def __init__(self, var_name, category, app_label, model_name, set_name,
date_field='pub_date', num=15):
"""Get latest objects of app_label.model_name"""
"""
Get latest objects of app_label.model_name
"""
self.category = Variable(category)
self.app_label = Variable(app_label)
self.model_name = Variable(model_name)
@ -243,43 +289,34 @@ class LatestObjectsNode(Node):
self.date_field = Variable(date_field)
self.num = Variable(num)
self.var_name = var_name
def get_cache_key(self, category, app_label, model_name, set_name,
date_field, num):
"""Get the cache key"""
key = 'latest_objects.%s' % '.'.join([category, app_label, model_name,
set_name, date_field, num])
def render(self, context):
"""Render this sucker"""
"""
Render this sucker
"""
category = resolve(self.category, context)
app_label = resolve(self.app_label, context)
model_name = resolve(self.model_name, context)
set_name = resolve(self.set_name, context)
date_field = resolve(self.date_field, context)
num = resolve(self.num, context)
cache_key = self.get_cache_key(category, app_label, model_name, set_name,
date_field, num)
result = cache.get(cache_key)
if not result:
result = get_latest_objects_by_category(category, app_label, model_name,
result = get_latest_objects_by_category(category, app_label, model_name,
set_name, date_field, num)
cache.set(key, result, 300)
context[self.var_name] = result
return ''
def do_get_latest_objects_by_category(parser, token):
"""
Get the latest objects by category
{% get_latest_objects_by_category category app_name model_name set_name [date_field] [number] as [var_name] %}
"""
proper_form = "{% get_latest_objects_by_category category app_name model_name set_name [date_field] [number] as [var_name] %}"
bits = token.split_contents()
if bits[-2] != 'as':
raise TemplateSyntaxError("%s tag shoud be in the form: %s" % (bits[0], proper_form))
if len(bits) < 7:
@ -299,9 +336,11 @@ def do_get_latest_objects_by_category(parser, token):
num = bits[6]
else:
num = None
return LatestObjectsNode(var_name, category, app_label, model_name, set_name,
return LatestObjectsNode(var_name, category, app_label, model_name, set_name,
date_field, num)
register.tag("get_latest_objects_by_category", do_get_latest_objects_by_category)
@register.filter
def tree_queryset(value):
@ -313,7 +352,7 @@ def tree_queryset(value):
from copy import deepcopy
if not isinstance(value, QuerySet):
return value
qs = value
qs2 = deepcopy(qs)
# Reaching into the bowels of query sets to find out whether the qs is
@ -331,9 +370,9 @@ def tree_queryset(value):
p.id not in include_pages:
ancestor_id_list = p.get_ancestors().values_list('id', flat=True)
include_pages.update(ancestor_id_list)
if include_pages:
qs = qs | qs.model._default_manager.filter(id__in=include_pages)
qs = qs.distinct()
return qs
return qs

View file

@ -1,11 +1,13 @@
from django.test import TestCase
from django import template
from categories.models import Category
class CategoryTagsTest(TestCase):
class GetCategoryTest(TestCase):
fixtures = ['musicgenres.json']
def render_template(self, template_string, context={}):
"""
Return the rendered string or raise an exception.
@ -16,27 +18,51 @@ class GetCategoryTest(TestCase):
def testTooFewArguments(self):
"""
Ensure that get_cateogry raises an exception if there aren't enough arguments.
Ensure that get_category raises an exception if there aren't enough arguments.
"""
self.assertRaises(template.TemplateSyntaxError, self.render_template, '{% load category_tags %}{% get_category %}')
def testTooManyArguments(self):
"""
Ensure that get_category raises an exception if there are too many arguments.
"""
self.assertRaises(template.TemplateSyntaxError, self.render_template, '{% load category_tags %}{% get_category "/Rock" as too many arguments %}')
def testAsIsSecondArgument(self):
"""
Test that the second argument to get_category is 'as'.
"""
self.assertRaises(template.TemplateSyntaxError, self.render_template, '{% load category_tags %}{% get_category "Rock" notas rock %}')
def testBasicUsage(self):
"""
Test that we can properly retrieve a category.
"""
rock_resp = u'\n<ul><li><a href="/categories/">Top</a>\n</li></ul>'
# display_path_as_ul
rock_resp = u'<ul><li><a href="/categories/">Top</a></li></ul>'
resp = self.render_template('{% load category_tags %}{% display_path_as_ul "/Rock" %}')
self.assertEqual(resp, rock_resp)
# display_drilldown_as_ul
expected_resp = u'<ul><li><a href="/categories/">Top</a><ul><li><a href="/categories/world/">World</a><ul><li><strong>Worldbeat</strong><ul><li><a href="/categories/world/worldbeat/afrobeat/">Afrobeat</a></li></ul></li></ul></li></ul></li></ul>'
resp = self.render_template('{% load category_tags %}'
'{% display_drilldown_as_ul "/World/Worldbeat" using="categories.category" %}')
self.assertEqual(resp, expected_resp)
# breadcrumbs
expected_resp = u'<a href="/categories/world/">World</a> &gt; Worldbeat'
resp = self.render_template('{% load category_tags %}'
'{% breadcrumbs "/World/Worldbeat" using="categories.category" %}')
self.assertEqual(resp, expected_resp)
# get_top_level_categories
expected_resp = u'Avant-garde|Blues|Country|Easy listening|Electronic|Hip hop/Rap music|Jazz|Latin|Modern folk|Pop|Reggae|Rhythm and blues|Rock|World|'
resp = self.render_template('{% load category_tags %}'
'{% get_top_level_categories using "categories.category" as varname %}'
'{% for item in varname %}{{ item }}|{% endfor %}')
self.assertEqual(resp, expected_resp)
# get_category_drilldown
expected_resp = u"World|World &gt; Worldbeat|"
resp = self.render_template('{% load category_tags %}'
'{% get_category_drilldown "/World" using "categories.category" as var %}'
'{% for item in var %}{{ item }}|{% endfor %}')
self.assertEqual(resp, expected_resp)
# recursetree
expected_resp = u'<ul><li><a href="/categories/">Top</a><ul><li><a href="/categories/world/">World</a></li></ul></li></ul>'
ctxt = {'nodes': Category.objects.filter(name__in=("Worldbeat", "Urban cowboy"))}
resp = self.render_template('{% load category_tags %}'
'<ul class="root">{% recursetree nodes|treeinfo %}<li>{{ node.name }}'
'{% if not node.is_leaf_node %}<ul class="children">{{ children }}'
'</ul>{% endif %}</li>{% endrecursetree %}</ul>', ctxt)
self.assertEqual(resp, expected_resp)

View file

@ -62,7 +62,7 @@ div.clearer {
.headerButton a:hover {
color: white;
background-color: #787878;
}
li#toc_button {
@ -121,7 +121,7 @@ right:0;
top: 84px;
bottom: 19px;
left: 0px;
width: 229px;
width: 229px;
background-color: #E4EBF7;
border-right: 1px solid #ACACAC;
border-top: 1px solid #2B334F;
@ -362,7 +362,7 @@ p.topic-title {
border:1px solid #111111;
margin:30px;
}
.admonition p {
.admonition p {
font: 12px 'Lucida Grande', Geneva, Helvetica, Arial, sans-serif;
margin-top: 7px;
margin-bottom: 0px;
@ -411,7 +411,7 @@ table.docutils td, table.docutils th {
table.docutils th {
font-weight: bold;
}
/* This alternates colors in up to six table rows (light blue for odd, white for even)*/
/* This alternates colors in up to six table rows (light blue for odd, white for even)*/
.docutils tr {
background: #F0F5F9;
}
@ -453,6 +453,7 @@ th {
dl {
margin-bottom: 15px;
font-size: 12px;
}
dd p {
@ -544,7 +545,7 @@ td.linenos pre {
}
td.code {
}
table.highlighttable {
@ -562,7 +563,6 @@ table.highlighttable td.linenos {
}
tt {
font-family:"Bitstream Vera Sans Mono",Monaco,"Lucida Console",Courier,Consolas,monospace;
}
tt.descname {
@ -643,7 +643,7 @@ dl.class dd dl.method dt {
padding: 3px;
background-color: #e9e9e9;
border-top: none;
}
dl.function dt {
@ -659,7 +659,7 @@ margin:0 0 0 30px;
padding:0 0 12px 6px;
}
#docstitle {
height: 36px;
height: 36px;
background-image: url(header_sm_mid.png);
left: 0;
top: 0;

View file

@ -1,33 +1,146 @@
=============
Template Tags
=============
=========================
Template tags and filters
=========================
get_top_level_categories
========================
.. contents::
:depth: 2
:local:
:backlinks: top
Retrieves an alphabetical list of all the categories that have no parents.
Syntax:
Filters
=======
``category_path``
-----------------
**Optional Parameter:** separator string. *Default:* ``" :: "``
Creates a path represented by a categories by joining the items with a separator.
Each path item will be coerced to unicode, so you can pass a list of category instances, if required.
**Example using a list of categories:**
.. code-block:: django
{% get_top_level_categories as categories %}
{{ some_list|category_path }}
Returns an list of categories ``[<category>, <category>, <category, ...]``
If ``some_list`` is ``[ <Category: Country>, <Category: Country pop>, <Category: Urban Cowboy>]`` the result will be::
Country :: Country pop :: Urban Cowboy
**Example using a category node and optional separator parameter:**
.. code-block:: django
{{ some_node.get_ancestors|category_path:" > " }}
If ``some_node`` was category "Urban Cowboy", the result will be::
Country > Country pop > Urban Cowboy
.. _tree_info:
``tree_info``
-------------
**Optional Parameter:** ``"ancestors"``
Given a list of categories, it iterates over the list, generating a tuple of the current category and a dict containing information about the tree structure around it, with the following keys:
``'new_level'``
``True`` if the current item is the start of a new level in the tree, ``False`` otherwise.
``'closed_levels'``
A list of levels which end after the current item. This will be an empty list if the next category's level is the same as or greater than the level of the current item.
Provide the optional argument, ``"ancestors"``, to add a list of unicode representations of the ancestors of the current category, in descending order (root node first, immediate parent last), under the key 'ancestors'.
For example: given the sample tree below, the contents of the list which would be available under the 'ancestors' key are given on the right::
Country -> []
Country pop -> [u'Country pop']
Urban Cowboy -> [u'Country', u'Country pop']
Using this filter with unpacking in a {% for %} tag, you should have enough information about the tree structure to create a hierarchical representation of the tree.
.. code-block:: django
{% for node,structure in objects|tree_info %}
{% if structure.new_level %}<ul><li>{% else %}</li><li>{% endif %}
{{ node.name }}
{% for level in structure.closed_levels %}</li></ul>{% endfor %}
{% endfor %}
``tree_queryset``
-----------------
Convert a regular category :py:class:`QuerySet` into a new, ordered :py:class:`QuerySet` that includes the categories selected and their ancestors.
This is especially helpful when you have a subset of categories and want to show the hierarchy for all the items.
For example, if we add it to the example for :ref:`tree_info`:
.. code-block:: django
{% for node,structure in objects|tree_queryset|tree_info %}
{% if structure.new_level %}<ul><li>{% else %}</li><li>{% endif %}
{{ node.name }}
{% for level in structure.closed_levels %}</li></ul>{% endfor %}
{% endfor %}
A list of unrelated categories such as ``[<Category: Urban cowboy>, <Category: Urban comtemporary>]``, the above template example will output the two categories and their ancestors:
.. code-block:: html
<ul><li>
Country
<ul><li>
Country pop
<ul><li>
Urban cowboy
</li></ul></li></ul></li></ul>
<ul><li>
Rhythm and blues
<ul><li>
Urban contemporary
</li></ul></li></ul>
.. note::
Categories that have similar ancestors are grouped accordingly. There is no duplication of the ancestor tree.
display_path_as_ul
==================
Inclusion tags
==============
Render the category with ancestors, but no children using the ``categories/ul_tree.html`` template.
``display_path_as_ul``
----------------------
Example:
**Template Rendered:** ``categories/ul_tree.html``
**Syntax 1:** ``{% display_path_as_ul <category_obj> %}``
**Syntax 2:** ``{% display_path_as_ul <path_string>[ using="app.Model"] %}``
Render the category with ancestors, but no children.
Pass either an object that subclasses :py:class:`CategoryBase` or a path string for the category. Add ``using="app.Model"`` to specify which model when using a path string. The default model used is :py:class:`Category`.
**Example, using Category model:**
.. code-block:: django
{% display_path_as_ul "/Grandparent/Parent" %}
or
**Example, using custom model:**
.. code-block:: django
{% display_path_as_ul "/Grandparent/Parent" using="coolapp.MusicGenre" %}
**Example, using an object:**
.. code-block:: django
@ -37,51 +150,39 @@ Returns:
.. code-block:: html
<ul>
<li><a href="/categories/">Top</a>
<ul>
<li><a href="/categories/grandparent/">Grandparent</a></li>
</ul>
</li>
</ul>
<ul>
<li><a href="/categories/">Top</a>
<ul>
<li><a href="/categories/grandparent/">Grandparent</a></li>
</ul>
</li>
</ul>
get_category_drilldown
======================
``display_drilldown_as_ul``
---------------------------
Retrieves the specified category, its ancestors and its immediate children
as an iterable.
**Template rendered:** ``categories/ul_tree.html``
Example:
**Syntax 1:** ``{% display_drilldown_as_ul category_obj %}``
.. code-block:: django
**Syntax 2:** ``{% display_drilldown_as_ul "/Grandparent/Parent" [using="app.Model"] %}``
{% get_category_drilldown "/Grandparent/Parent" as family %}
Render the category with ancestors and children.
or
.. code-block:: django
{% get_category_drilldown category_obj as family %}
Sets ``family`` to::
[Grandparent, Parent, Child 1, Child 2, Child n]
display_drilldown_as_ul
=======================
Render the category with ancestors and children using the
``categories/ul_tree.html`` template.
Example:
**Example, using Category model:**
.. code-block:: django
{% display_drilldown_as_ul "/Grandparent/Parent" %}
or:
**Example, using custom model:**
.. code-block:: django
{% display_drilldown_as_ul "/Grandparent/Parent" using="coolapp.MusicGenre" %}
**Example, using an object:**
.. code-block:: django
@ -110,18 +211,30 @@ Returns:
</ul>
breadcrumbs tag
===============
``breadcrumbs tag``
-------------------
Render breadcrumbs, using the ``categories/breadcrumbs.html`` template, using the optional ``separator`` argument.
**Template rendered:** ``categories/breadcrumbs.html``
Example:
**Syntax 1:** ``{% breadcrumbs category_obj [separator=" :: "] %}``
**Syntax 2:** ``{% breadcrumbs "/Grandparent/Parent" [separator=" :: "] [using="app.Model"] %}``
Render breadcrumbs for the given path using ``::`` or the given separator.
**Example using Category model:**
.. code-block:: django
{% breadcrumbs "/Grandparent/Parent" %}
or:
**Example using a custom model:**
.. code-block:: django
{% breadcrumbs "/Grandparent/Parent" using="coolapp.MusicGenre" %}
**Example using an object:**
.. code-block:: django
@ -133,14 +246,103 @@ Returns:
<a href="/categories/grandparent/">Grandparent</a> / Parent
You can alter the separator used in the template by adding a string argument to be the separator:
You can alter the separator used in the template by adding a separator argument:
.. code-block:: django
{% breadcrumbs category_obj "::" %}
{% breadcrumbs category_obj separator=" &gt; " %}
Returns:
.. code-block:: html
<a href="/categories/grandparent/">Grandparent</a> :: Parent
<a href="/categories/grandparent/">Grandparent</a> &gt; Parent
Template Tags
=============
``get_top_level_categories``
----------------------------
Retrieves an alphabetical list of all the categories that have no parents.
Syntax:
.. code-block:: django
{% get_top_level_categories [using "app.Model"] as categories %}
Returns an list of categories ``[<category>, <category>, <category, ...]``
``get_category_drilldown``
--------------------------
**Syntax 1:** ``{% get_category_drilldown <path_string> [using "app.Model"] as <varname> %}``
**Syntax 2:** ``{% get_category_drilldown <object> as <varname> %}``
Retrieves the specified category, its ancestors and its immediate children as an iterable. Syntax 1 allows for the retrieval of the category object via a slash-delimited path. The optional ``using "app.Model"`` allows you to specify from which model to retrieve the object.
Example:
.. code-block:: django
{% get_category_drilldown "/Grandparent/Parent" using "family.Member" as family %}
The second syntax uses an instance of any object that subclasses :py:class:`CategoryBase`
.. code-block:: django
{% get_category_drilldown category_obj as family %}
Both examples sets ``family`` to::
[Grandparent, Parent, Child 1, Child 2, Child n]
``recursetree``
---------------
This tag renders a section of your template recursively for each node in your
tree.
For example:
.. code-block:: django
<ul class="root">
{% recursetree nodes %}
<li>
{{ node.name }}
{% if not node.is_leaf_node %}
<ul class="children">
{{ children }}
</ul>
{% endif %}
</li>
{% endrecursetree %}
</ul>
Note the special variables ``node`` and ``children``.
These are magically inserted into your context while you're inside the
``recursetree`` tag.
``node`` is an instance of your MPTT model.
``children`` : This variable holds the rendered HTML for the children of
``node``.
.. note::
If you already have variables called ``node`` or ``children`` in your
template, and you need to access them inside the ``recursetree`` block,
you'll need to alias them to some other name first:
.. code-block:: django
{% with node as friendly_node %}
{% recursetree nodes %}
{{ node.name }} is friends with {{ friendly_node.name }}
{{ children }}
{% endrecursetree %}
{% endwith %}

View file

@ -1,33 +1,146 @@
=============
Template Tags
=============
=========================
Template tags and filters
=========================
get_top_level_categories
========================
.. contents::
:depth: 2
:local:
:backlinks: top
Retrieves an alphabetical list of all the categories that have no parents.
Syntax:
Filters
=======
``category_path``
-----------------
**Optional Parameter:** separator string. *Default:* ``" :: "``
Creates a path represented by a categories by joining the items with a separator.
Each path item will be coerced to unicode, so you can pass a list of category instances, if required.
**Example using a list of categories:**
.. code-block:: django
{% get_top_level_categories as categories %}
{{ some_list|category_path }}
Returns an list of categories ``[<category>, <category>, <category, ...]``
If ``some_list`` is ``[ <Category: Country>, <Category: Country pop>, <Category: Urban Cowboy>]`` the result will be::
Country :: Country pop :: Urban Cowboy
**Example using a category node and optional separator parameter:**
.. code-block:: django
{{ some_node.get_ancestors|category_path:" > " }}
If ``some_node`` was category "Urban Cowboy", the result will be::
Country > Country pop > Urban Cowboy
.. _tree_info:
``tree_info``
-------------
**Optional Parameter:** ``"ancestors"``
Given a list of categories, it iterates over the list, generating a tuple of the current category and a dict containing information about the tree structure around it, with the following keys:
``'new_level'``
``True`` if the current item is the start of a new level in the tree, ``False`` otherwise.
``'closed_levels'``
A list of levels which end after the current item. This will be an empty list if the next category's level is the same as or greater than the level of the current item.
Provide the optional argument, ``"ancestors"``, to add a list of unicode representations of the ancestors of the current category, in descending order (root node first, immediate parent last), under the key 'ancestors'.
For example: given the sample tree below, the contents of the list which would be available under the 'ancestors' key are given on the right::
Country -> []
Country pop -> [u'Country pop']
Urban Cowboy -> [u'Country', u'Country pop']
Using this filter with unpacking in a {% for %} tag, you should have enough information about the tree structure to create a hierarchical representation of the tree.
.. code-block:: django
{% for node,structure in objects|tree_info %}
{% if structure.new_level %}<ul><li>{% else %}</li><li>{% endif %}
{{ node.name }}
{% for level in structure.closed_levels %}</li></ul>{% endfor %}
{% endfor %}
``tree_queryset``
-----------------
Convert a regular category :py:class:`QuerySet` into a new, ordered :py:class:`QuerySet` that includes the categories selected and their ancestors.
This is especially helpful when you have a subset of categories and want to show the hierarchy for all the items.
For example, if we add it to the example for :ref:`tree_info`:
.. code-block:: django
{% for node,structure in objects|tree_queryset|tree_info %}
{% if structure.new_level %}<ul><li>{% else %}</li><li>{% endif %}
{{ node.name }}
{% for level in structure.closed_levels %}</li></ul>{% endfor %}
{% endfor %}
A list of unrelated categories such as ``[<Category: Urban cowboy>, <Category: Urban comtemporary>]``, the above template example will output the two categories and their ancestors:
.. code-block:: html
<ul><li>
Country
<ul><li>
Country pop
<ul><li>
Urban cowboy
</li></ul></li></ul></li></ul>
<ul><li>
Rhythm and blues
<ul><li>
Urban contemporary
</li></ul></li></ul>
.. note::
Categories that have similar ancestors are grouped accordingly. There is no duplication of the ancestor tree.
display_path_as_ul
==================
Inclusion tags
==============
Render the category with ancestors, but no children using the ``categories/ul_tree.html`` template.
``display_path_as_ul``
----------------------
Example:
**Template Rendered:** ``categories/ul_tree.html``
**Syntax 1:** ``{% display_path_as_ul <category_obj> %}``
**Syntax 2:** ``{% display_path_as_ul <path_string>[ using="app.Model"] %}``
Render the category with ancestors, but no children.
Pass either an object that subclasses :py:class:`CategoryBase` or a path string for the category. Add ``using="app.Model"`` to specify which model when using a path string. The default model used is :py:class:`Category`.
**Example, using Category model:**
.. code-block:: django
{% display_path_as_ul "/Grandparent/Parent" %}
or
**Example, using custom model:**
.. code-block:: django
{% display_path_as_ul "/Grandparent/Parent" using="coolapp.MusicGenre" %}
**Example, using an object:**
.. code-block:: django
@ -37,51 +150,39 @@ Returns:
.. code-block:: html
<ul>
<li><a href="/categories/">Top</a>
<ul>
<li><a href="/categories/grandparent/">Grandparent</a></li>
</ul>
</li>
</ul>
<ul>
<li><a href="/categories/">Top</a>
<ul>
<li><a href="/categories/grandparent/">Grandparent</a></li>
</ul>
</li>
</ul>
get_category_drilldown
======================
``display_drilldown_as_ul``
---------------------------
Retrieves the specified category, its ancestors and its immediate children
as an iterable.
**Template rendered:** ``categories/ul_tree.html``
Example:
**Syntax 1:** ``{% display_drilldown_as_ul category_obj %}``
.. code-block:: django
**Syntax 2:** ``{% display_drilldown_as_ul "/Grandparent/Parent" [using="app.Model"] %}``
{% get_category_drilldown "/Grandparent/Parent" as family %}
Render the category with ancestors and children.
or
.. code-block:: django
{% get_category_drilldown category_obj as family %}
Sets ``family`` to::
[Grandparent, Parent, Child 1, Child 2, Child n]
display_drilldown_as_ul
=======================
Render the category with ancestors and children using the
``categories/ul_tree.html`` template.
Example:
**Example, using Category model:**
.. code-block:: django
{% display_drilldown_as_ul "/Grandparent/Parent" %}
or:
**Example, using custom model:**
.. code-block:: django
{% display_drilldown_as_ul "/Grandparent/Parent" using="coolapp.MusicGenre" %}
**Example, using an object:**
.. code-block:: django
@ -110,18 +211,30 @@ Returns:
</ul>
breadcrumbs tag
===============
``breadcrumbs tag``
-------------------
Render breadcrumbs, using the ``categories/breadcrumbs.html`` template, using the optional ``separator`` argument.
**Template rendered:** ``categories/breadcrumbs.html``
Example:
**Syntax 1:** ``{% breadcrumbs category_obj [separator=" :: "] %}``
**Syntax 2:** ``{% breadcrumbs "/Grandparent/Parent" [separator=" :: "] [using="app.Model"] %}``
Render breadcrumbs for the given path using ``::`` or the given separator.
**Example using Category model:**
.. code-block:: django
{% breadcrumbs "/Grandparent/Parent" %}
or:
**Example using a custom model:**
.. code-block:: django
{% breadcrumbs "/Grandparent/Parent" using="coolapp.MusicGenre" %}
**Example using an object:**
.. code-block:: django
@ -133,14 +246,103 @@ Returns:
<a href="/categories/grandparent/">Grandparent</a> / Parent
You can alter the separator used in the template by adding a string argument to be the separator:
You can alter the separator used in the template by adding a separator argument:
.. code-block:: django
{% breadcrumbs category_obj "::" %}
{% breadcrumbs category_obj separator=" &gt; " %}
Returns:
.. code-block:: html
<a href="/categories/grandparent/">Grandparent</a> :: Parent
<a href="/categories/grandparent/">Grandparent</a> &gt; Parent
Template Tags
=============
``get_top_level_categories``
----------------------------
Retrieves an alphabetical list of all the categories that have no parents.
Syntax:
.. code-block:: django
{% get_top_level_categories [using "app.Model"] as categories %}
Returns an list of categories ``[<category>, <category>, <category, ...]``
``get_category_drilldown``
--------------------------
**Syntax 1:** ``{% get_category_drilldown <path_string> [using "app.Model"] as <varname> %}``
**Syntax 2:** ``{% get_category_drilldown <object> as <varname> %}``
Retrieves the specified category, its ancestors and its immediate children as an iterable. Syntax 1 allows for the retrieval of the category object via a slash-delimited path. The optional ``using "app.Model"`` allows you to specify from which model to retrieve the object.
Example:
.. code-block:: django
{% get_category_drilldown "/Grandparent/Parent" using "family.Member" as family %}
The second syntax uses an instance of any object that subclasses :py:class:`CategoryBase`
.. code-block:: django
{% get_category_drilldown category_obj as family %}
Both examples sets ``family`` to::
[Grandparent, Parent, Child 1, Child 2, Child n]
``recursetree``
---------------
This tag renders a section of your template recursively for each node in your
tree.
For example:
.. code-block:: django
<ul class="root">
{% recursetree nodes %}
<li>
{{ node.name }}
{% if not node.is_leaf_node %}
<ul class="children">
{{ children }}
</ul>
{% endif %}
</li>
{% endrecursetree %}
</ul>
Note the special variables ``node`` and ``children``.
These are magically inserted into your context while you're inside the
``recursetree`` tag.
``node`` is an instance of your MPTT model.
``children`` : This variable holds the rendered HTML for the children of
``node``.
.. note::
If you already have variables called ``node`` or ``children`` in your
template, and you need to access them inside the ``recursetree`` block,
you'll need to alias them to some other name first:
.. code-block:: django
{% with node as friendly_node %}
{% recursetree nodes %}
{{ node.name }} is friends with {{ friendly_node.name }}
{{ children }}
{% endrecursetree %}
{% endwith %}

View file

@ -4,7 +4,7 @@
*
* Sphinx stylesheet -- basic theme.
*
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
* :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
@ -79,14 +79,6 @@ div.sphinxsidebar input {
font-size: 1em;
}
div.sphinxsidebar input[type="text"] {
width: 170px;
}
div.sphinxsidebar input[type="submit"] {
width: 30px;
}
img {
border: 0;
}
@ -244,6 +236,7 @@ img.align-center, .figure.align-center, object.align-center {
}
.align-center {
clear: both;
text-align: center;
}
@ -420,7 +413,7 @@ dl.glossary dt {
}
.footnote:target {
background-color: #ffa;
background-color: #ffa
}
.line-block {
@ -447,16 +440,10 @@ dl.glossary dt {
font-style: oblique;
}
abbr, acronym {
border-bottom: dotted 1px;
cursor: help;
}
/* -- code displays --------------------------------------------------------- */
pre {
overflow: auto;
overflow-y: hidden; /* fixes display issues on Chrome browsers */
}
td.linenos pre {
@ -537,4 +524,4 @@ span.eqno {
#top-link {
display: none;
}
}
}

View file

@ -62,7 +62,7 @@ div.clearer {
.headerButton a:hover {
color: white;
background-color: #787878;
}
li#toc_button {
@ -121,7 +121,7 @@ right:0;
top: 84px;
bottom: 19px;
left: 0px;
width: 229px;
width: 229px;
background-color: #E4EBF7;
border-right: 1px solid #ACACAC;
border-top: 1px solid #2B334F;
@ -362,7 +362,7 @@ p.topic-title {
border:1px solid #111111;
margin:30px;
}
.admonition p {
.admonition p {
font: 12px 'Lucida Grande', Geneva, Helvetica, Arial, sans-serif;
margin-top: 7px;
margin-bottom: 0px;
@ -411,7 +411,7 @@ table.docutils td, table.docutils th {
table.docutils th {
font-weight: bold;
}
/* This alternates colors in up to six table rows (light blue for odd, white for even)*/
/* This alternates colors in up to six table rows (light blue for odd, white for even)*/
.docutils tr {
background: #F0F5F9;
}
@ -453,6 +453,7 @@ th {
dl {
margin-bottom: 15px;
font-size: 12px;
}
dd p {
@ -544,7 +545,7 @@ td.linenos pre {
}
td.code {
}
table.highlighttable {
@ -562,7 +563,6 @@ table.highlighttable td.linenos {
}
tt {
font-family:"Bitstream Vera Sans Mono",Monaco,"Lucida Console",Courier,Consolas,monospace;
}
tt.descname {
@ -643,7 +643,7 @@ dl.class dd dl.method dt {
padding: 3px;
background-color: #e9e9e9;
border-top: none;
}
dl.function dt {
@ -659,7 +659,7 @@ margin:0 0 0 30px;
padding:0 0 12px 6px;
}
#docstitle {
height: 36px;
height: 36px;
background-image: url(header_sm_mid.png);
left: 0;
top: 0;

View file

@ -2,9 +2,9 @@
* doctools.js
* ~~~~~~~~~~~
*
* Sphinx JavaScript utilities for all documentation.
* Sphinx JavaScript utilties for all documentation.
*
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
* :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
@ -185,9 +185,9 @@ var Documentation = {
body.highlightText(this.toLowerCase(), 'highlighted');
});
}, 10);
$('<p class="highlight-link"><a href="javascript:Documentation.' +
'hideSearchWords()">' + _('Hide Search Matches') + '</a></p>')
.appendTo($('#searchbox'));
$('<li class="highlight-link"><a href="javascript:Documentation.' +
'hideSearchWords()">' + _('Hide Search Matches') + '</a></li>')
.appendTo($('.sidebar .this-page-menu'));
}
},
@ -213,7 +213,7 @@ var Documentation = {
* helper function to hide the search marks again
*/
hideSearchWords : function() {
$('#searchbox .highlight-link').fadeOut(300);
$('.sidebar .this-page-menu li.highlight-link').fadeOut(300);
$('span.highlighted').removeClass('highlighted');
},

View file

@ -1,10 +1,10 @@
/*
* searchtools.js_t
* ~~~~~~~~~~~~~~~~
* searchtools.js
* ~~~~~~~~~~~~~~
*
* Sphinx JavaScript utilties for the full-text search.
*
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
* :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
@ -36,11 +36,10 @@ jQuery.makeSearchSummary = function(text, keywords, hlwords) {
return rv;
}
/**
* Porter Stemmer
*/
var Stemmer = function() {
var PorterStemmer = function() {
var step2list = {
ational: 'ate',
@ -301,20 +300,20 @@ var Search = {
},
query : function(query) {
var stopwords = ["and","then","into","it","as","are","in","if","for","no","there","their","was","is","be","to","that","but","they","not","such","with","by","a","on","these","of","will","this","near","the","or","at"];
var stopwords = ['and', 'then', 'into', 'it', 'as', 'are', 'in',
'if', 'for', 'no', 'there', 'their', 'was', 'is',
'be', 'to', 'that', 'but', 'they', 'not', 'such',
'with', 'by', 'a', 'on', 'these', 'of', 'will',
'this', 'near', 'the', 'or', 'at'];
// Stem the searchterms and add them to the correct list
var stemmer = new Stemmer();
// stem the searchterms and add them to the correct list
var stemmer = new PorterStemmer();
var searchterms = [];
var excluded = [];
var hlterms = [];
var tmp = query.split(/\s+/);
var objectterms = [];
var object = (tmp.length == 1) ? tmp[0].toLowerCase() : null;
for (var i = 0; i < tmp.length; i++) {
if (tmp[i] != "") {
objectterms.push(tmp[i].toLowerCase());
}
if ($u.indexOf(stopwords, tmp[i]) != -1 || tmp[i].match(/^\d+$/) ||
tmp[i] == "") {
// skip this "word"
@ -345,6 +344,9 @@ var Search = {
var filenames = this._index.filenames;
var titles = this._index.titles;
var terms = this._index.terms;
var objects = this._index.objects;
var objtypes = this._index.objtypes;
var objnames = this._index.objnames;
var fileMap = {};
var files = null;
// different result priorities
@ -355,19 +357,40 @@ var Search = {
$('#search-progress').empty();
// lookup as object
for (var i = 0; i < objectterms.length; i++) {
var others = [].concat(objectterms.slice(0,i),
objectterms.slice(i+1, objectterms.length))
var results = this.performObjectSearch(objectterms[i], others);
// Assume first word is most likely to be the object,
// other words more likely to be in description.
// Therefore put matches for earlier words first.
// (Results are eventually used in reverse order).
objectResults = results[0].concat(objectResults);
importantResults = results[1].concat(importantResults);
unimportantResults = results[2].concat(unimportantResults);
if (object != null) {
for (var prefix in objects) {
for (var name in objects[prefix]) {
var fullname = (prefix ? prefix + '.' : '') + name;
if (fullname.toLowerCase().indexOf(object) > -1) {
match = objects[prefix][name];
descr = objnames[match[1]] + _(', in ') + titles[match[0]];
// XXX the generated anchors are not generally correct
// XXX there may be custom prefixes
result = [filenames[match[0]], fullname, '#'+fullname, descr];
switch (match[2]) {
case 1: objectResults.push(result); break;
case 0: importantResults.push(result); break;
case 2: unimportantResults.push(result); break;
}
}
}
}
}
// sort results descending
objectResults.sort(function(a, b) {
return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
});
importantResults.sort(function(a, b) {
return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
});
unimportantResults.sort(function(a, b) {
return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
});
// perform the search on the required terms
for (var i = 0; i < searchterms.length; i++) {
var word = searchterms[i];
@ -466,7 +489,7 @@ var Search = {
listItem.slideDown(5, function() {
displayNextItem();
});
}, "text");
});
} else {
// no source available, just display title
Search.output.append(listItem);
@ -487,74 +510,9 @@ var Search = {
}
}
displayNextItem();
},
performObjectSearch : function(object, otherterms) {
var filenames = this._index.filenames;
var objects = this._index.objects;
var objnames = this._index.objnames;
var titles = this._index.titles;
var importantResults = [];
var objectResults = [];
var unimportantResults = [];
for (var prefix in objects) {
for (var name in objects[prefix]) {
var fullname = (prefix ? prefix + '.' : '') + name;
if (fullname.toLowerCase().indexOf(object) > -1) {
var match = objects[prefix][name];
var objname = objnames[match[1]][2];
var title = titles[match[0]];
// If more than one term searched for, we require other words to be
// found in the name/title/description
if (otherterms.length > 0) {
var haystack = (prefix + ' ' + name + ' ' +
objname + ' ' + title).toLowerCase();
var allfound = true;
for (var i = 0; i < otherterms.length; i++) {
if (haystack.indexOf(otherterms[i]) == -1) {
allfound = false;
break;
}
}
if (!allfound) {
continue;
}
}
var descr = objname + _(', in ') + title;
anchor = match[3];
if (anchor == '')
anchor = fullname;
else if (anchor == '-')
anchor = objnames[match[1]][1] + '-' + fullname;
result = [filenames[match[0]], fullname, '#'+anchor, descr];
switch (match[2]) {
case 1: objectResults.push(result); break;
case 0: importantResults.push(result); break;
case 2: unimportantResults.push(result); break;
}
}
}
}
// sort results descending
objectResults.sort(function(a, b) {
return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
});
importantResults.sort(function(a, b) {
return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
});
unimportantResults.sort(function(a, b) {
return (a[1] > b[1]) ? -1 : ((a[1] < b[1]) ? 1 : 0);
});
return [importantResults, objectResults, unimportantResults]
}
}
$(document).ready(function() {
Search.init();
});
});

View file

@ -16,7 +16,7 @@
* Once the browser is closed the cookie is deleted and the position
* reset to the default (expanded).
*
* :copyright: Copyright 2007-2011 by the Sphinx team, see AUTHORS.
* :copyright: Copyright 2007-2010 by the Sphinx team, see AUTHORS.
* :license: BSD, see LICENSE for details.
*
*/
@ -29,9 +29,6 @@ $(function() {
var sidebar = $('.sphinxsidebar');
var sidebarwrapper = $('.sphinxsidebarwrapper');
// for some reason, the document has no sidebar; do not run into errors
if (!sidebar.length) return;
// original margin-left of the bodywrapper and width of the sidebar
// with the sidebar expanded
var bw_margin_expanded = bodywrapper.css('margin-left');

View file

@ -1,10 +1,3 @@
// Underscore.js 0.5.5
// (c) 2009 Jeremy Ashkenas, DocumentCloud Inc.
// Underscore is freely distributable under the terms of the MIT license.
// Portions of Underscore are inspired by or borrowed from Prototype.js,
// Oliver Steele's Functional, and John Resig's Micro-Templating.
// For all details and documentation:
// http://documentcloud.github.com/underscore/
(function(){var j=this,n=j._,i=function(a){this._wrapped=a},m=typeof StopIteration!=="undefined"?StopIteration:"__break__",b=j._=function(a){return new i(a)};if(typeof exports!=="undefined")exports._=b;var k=Array.prototype.slice,o=Array.prototype.unshift,p=Object.prototype.toString,q=Object.prototype.hasOwnProperty,r=Object.prototype.propertyIsEnumerable;b.VERSION="0.5.5";b.each=function(a,c,d){try{if(a.forEach)a.forEach(c,d);else if(b.isArray(a)||b.isArguments(a))for(var e=0,f=a.length;e<f;e++)c.call(d,
a[e],e,a);else{var g=b.keys(a);f=g.length;for(e=0;e<f;e++)c.call(d,a[g[e]],g[e],a)}}catch(h){if(h!=m)throw h;}return a};b.map=function(a,c,d){if(a&&b.isFunction(a.map))return a.map(c,d);var e=[];b.each(a,function(f,g,h){e.push(c.call(d,f,g,h))});return e};b.reduce=function(a,c,d,e){if(a&&b.isFunction(a.reduce))return a.reduce(b.bind(d,e),c);b.each(a,function(f,g,h){c=d.call(e,c,f,g,h)});return c};b.reduceRight=function(a,c,d,e){if(a&&b.isFunction(a.reduceRight))return a.reduceRight(b.bind(d,e),c);
var f=b.clone(b.toArray(a)).reverse();b.each(f,function(g,h){c=d.call(e,c,g,h,a)});return c};b.detect=function(a,c,d){var e;b.each(a,function(f,g,h){if(c.call(d,f,g,h)){e=f;b.breakLoop()}});return e};b.select=function(a,c,d){if(a&&b.isFunction(a.filter))return a.filter(c,d);var e=[];b.each(a,function(f,g,h){c.call(d,f,g,h)&&e.push(f)});return e};b.reject=function(a,c,d){var e=[];b.each(a,function(f,g,h){!c.call(d,f,g,h)&&e.push(f)});return e};b.all=function(a,c,d){c=c||b.identity;if(a&&b.isFunction(a.every))return a.every(c,

View file

@ -2,16 +2,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Adding the fields to the database &mdash; Django Categories 1.0.5 documentation</title>
<title>Adding the fields to the database &mdash; Django Categories v1.0.5 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: '',
@ -24,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 1.0.5 documentation" href="index.html" />
<link rel="top" title="Django Categories v1.0.5 documentation" href="index.html" />
<link rel="next" title="Creating Custom Categories" href="custom_categories.html" />
<link rel="prev" title="Registering Models" href="registering_models.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories 1.0.5 documentation</p>
<p>Django Categories v1.0.5 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Adding the fields to the database</h1></div>
@ -116,7 +113,7 @@
<div class="footer">
<p>
&copy; Copyright 2010-2012, Corey Oordt.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.5.
</p>
</div>
<div class="clearer"></div>

View file

@ -2,16 +2,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Creating Custom Categories &mdash; Django Categories 1.0.5 documentation</title>
<title>Creating Custom Categories &mdash; Django Categories v1.0.5 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: '',
@ -24,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 1.0.5 documentation" href="index.html" />
<link rel="top" title="Django Categories v1.0.5 documentation" href="index.html" />
<link rel="next" title="Reference" href="reference/index.html" />
<link rel="prev" title="Adding the fields to the database" href="adding_the_fields.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories 1.0.5 documentation</p>
<p>Django Categories v1.0.5 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Creating Custom Categories</h1></div>
@ -328,7 +325,7 @@
<div class="footer">
<p>
&copy; Copyright 2010-2012, Corey Oordt.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.5.
</p>
</div>
<div class="clearer"></div>

View file

@ -1,19 +1,14 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Index &mdash; Django Categories 1.0.5 documentation</title>
<title>Index &mdash; Django Categories v1.0.5 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: '',
@ -26,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 1.0.5 documentation" href="index.html" />
<link rel="top" title="Django Categories v1.0.5 documentation" href="index.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories 1.0.5 documentation</p>
<p>Django Categories v1.0.5 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Index</h1></div>
@ -86,167 +81,100 @@
<div class="body">
<h1 id="index">Index</h1>
<h1 id="index">Index</h1>
<div class="genindex-jumpbox">
<a href="#A"><strong>A</strong></a>
| <a href="#C"><strong>C</strong></a>
| <a href="#D"><strong>D</strong></a>
| <a href="#M"><strong>M</strong></a>
| <a href="#N"><strong>N</strong></a>
| <a href="#O"><strong>O</strong></a>
| <a href="#P"><strong>P</strong></a>
| <a href="#R"><strong>R</strong></a>
| <a href="#S"><strong>S</strong></a>
| <a href="#T"><strong>T</strong></a>
</div>
<div class="genindex-jumpbox">
<a href="#A"><strong>A</strong></a> | <a href="#C"><strong>C</strong></a> | <a href="#D"><strong>D</strong></a> | <a href="#M"><strong>M</strong></a> | <a href="#N"><strong>N</strong></a> | <a href="#O"><strong>O</strong></a> | <a href="#P"><strong>P</strong></a> | <a href="#R"><strong>R</strong></a> | <a href="#S"><strong>S</strong></a> | <a href="#T"><strong>T</strong></a>
</div>
<h2 id="A">A</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
<dt><a href="reference/models.html#CategoryBase.active">active (CategoryBase attribute)</a>
</dt>
<dt><a href="reference/models.html#Category.alternate_title">alternate_title (Category attribute)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="reference/models.html#Category.alternate_url">alternate_url (Category attribute)</a>
</dt>
</dl></td>
<table width="100%" class="indextable genindextable"><tr>
<td width="33%" valign="top"><dl>
<dt><a href="reference/models.html#CategoryBase.active">active (CategoryBase attribute)</a></dt>
<dt><a href="reference/models.html#Category.alternate_title">alternate_title (Category attribute)</a></dt>
</dl></td>
<td width="33%" valign="top"><dl>
<dt><a href="reference/models.html#Category.alternate_url">alternate_url (Category attribute)</a></dt>
</dl></td>
</tr></table>
<h2 id="C">C</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
<dt><a href="reference/models.html#Category">Category (built-in class)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="reference/models.html#CategoryBase">CategoryBase (built-in class)</a>
</dt>
</dl></td>
<table width="100%" class="indextable genindextable"><tr>
<td width="33%" valign="top"><dl>
<dt><a href="reference/models.html#Category">Category (built-in class)</a></dt>
</dl></td>
<td width="33%" valign="top"><dl>
<dt><a href="reference/models.html#CategoryBase">CategoryBase (built-in class)</a></dt>
</dl></td>
</tr></table>
<h2 id="D">D</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
<dt><a href="reference/models.html#Category.description">description (Category attribute)</a>
</dt>
</dl></td>
<table width="100%" class="indextable genindextable"><tr>
<td width="33%" valign="top"><dl>
<dt><a href="reference/models.html#Category.description">description (Category attribute)</a></dt>
</dl></td>
</tr></table>
<h2 id="M">M</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
<dt><a href="reference/models.html#Category.meta_extra">meta_extra (Category attribute)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="reference/models.html#Category.meta_keywords">meta_keywords (Category attribute)</a>
</dt>
</dl></td>
<table width="100%" class="indextable genindextable"><tr>
<td width="33%" valign="top"><dl>
<dt><a href="reference/models.html#Category.meta_extra">meta_extra (Category attribute)</a></dt>
</dl></td>
<td width="33%" valign="top"><dl>
<dt><a href="reference/models.html#Category.meta_keywords">meta_keywords (Category attribute)</a></dt>
</dl></td>
</tr></table>
<h2 id="N">N</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
<dt><a href="reference/models.html#CategoryBase.name">name (CategoryBase attribute)</a>
</dt>
</dl></td>
<table width="100%" class="indextable genindextable"><tr>
<td width="33%" valign="top"><dl>
<dt><a href="reference/models.html#CategoryBase.name">name (CategoryBase attribute)</a></dt>
</dl></td>
</tr></table>
<h2 id="O">O</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
<dt><a href="reference/models.html#CategoryBase.objects">objects (CategoryBase attribute)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="reference/models.html#Category.order">order (Category attribute)</a>
</dt>
</dl></td>
<table width="100%" class="indextable genindextable"><tr>
<td width="33%" valign="top"><dl>
<dt><a href="reference/models.html#CategoryBase.objects">objects (CategoryBase attribute)</a></dt>
</dl></td>
<td width="33%" valign="top"><dl>
<dt><a href="reference/models.html#Category.order">order (Category attribute)</a></dt>
</dl></td>
</tr></table>
<h2 id="P">P</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
<dt><a href="reference/models.html#CategoryBase.parent">parent (CategoryBase attribute)</a>
</dt>
</dl></td>
<table width="100%" class="indextable genindextable"><tr>
<td width="33%" valign="top"><dl>
<dt><a href="reference/models.html#CategoryBase.parent">parent (CategoryBase attribute)</a></dt>
</dl></td>
</tr></table>
<h2 id="R">R</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
<dt><a href="registering_models.html#register_fk">register_fk() (built-in function)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="registering_models.html#register_m2m">register_m2m() (built-in function)</a>
</dt>
</dl></td>
<table width="100%" class="indextable genindextable"><tr>
<td width="33%" valign="top"><dl>
<dt><a href="registering_models.html#register_fk">register_fk() (built-in function)</a></dt>
</dl></td>
<td width="33%" valign="top"><dl>
<dt><a href="registering_models.html#register_m2m">register_m2m() (built-in function)</a></dt>
</dl></td>
</tr></table>
<h2 id="S">S</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
<dt><a href="reference/models.html#CategoryBase.slug">slug (CategoryBase attribute)</a>
</dt>
</dl></td>
<table width="100%" class="indextable genindextable"><tr>
<td width="33%" valign="top"><dl>
<dt><a href="reference/models.html#CategoryBase.slug">slug (CategoryBase attribute)</a></dt>
</dl></td>
</tr></table>
<h2 id="T">T</h2>
<table style="width: 100%" class="indextable genindextable"><tr>
<td style="width: 33%" valign="top"><dl>
<dt><a href="reference/models.html#Category.thumbnail">thumbnail (Category attribute)</a>
</dt>
<dt><a href="reference/models.html#Category.thumbnail_height">thumbnail_height (Category attribute)</a>
</dt>
</dl></td>
<td style="width: 33%" valign="top"><dl>
<dt><a href="reference/models.html#Category.thumbnail_width">thumbnail_width (Category attribute)</a>
</dt>
<dt><a href="reference/models.html#CategoryBase.tree">tree (CategoryBase attribute)</a>
</dt>
</dl></td>
<table width="100%" class="indextable genindextable"><tr>
<td width="33%" valign="top"><dl>
<dt><a href="reference/models.html#Category.thumbnail">thumbnail (Category attribute)</a></dt>
<dt><a href="reference/models.html#Category.thumbnail_height">thumbnail_height (Category attribute)</a></dt>
</dl></td>
<td width="33%" valign="top"><dl>
<dt><a href="reference/models.html#Category.thumbnail_width">thumbnail_width (Category attribute)</a></dt>
<dt><a href="reference/models.html#CategoryBase.tree">tree (CategoryBase attribute)</a></dt>
</dl></td>
</tr></table>
@ -257,7 +185,7 @@
<div class="footer">
<p>
&copy; Copyright 2010-2012, Corey Oordt.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.5.
</p>
</div>
<div class="clearer"></div>

View file

@ -2,16 +2,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Getting Started &mdash; Django Categories 1.0.5 documentation</title>
<title>Getting Started &mdash; Django Categories v1.0.5 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: '',
@ -24,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 1.0.5 documentation" href="index.html" />
<link rel="top" title="Django Categories v1.0.5 documentation" href="index.html" />
<link rel="next" title="Using categories in templates" href="usage.html" />
<link rel="prev" title="Installation" href="installation.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories 1.0.5 documentation</p>
<p>Django Categories v1.0.5 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Getting Started</h1></div>
@ -155,7 +152,7 @@ Subject 2
<div class="footer">
<p>
&copy; Copyright 2010-2012, Corey Oordt.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.5.
</p>
</div>
<div class="clearer"></div>

View file

@ -2,16 +2,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Django Categories v 1.0 &mdash; Django Categories 1.0.5 documentation</title>
<title>Django Categories v 1.0 &mdash; Django Categories v1.0.5 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: '',
@ -24,12 +21,12 @@
<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 1.0.5 documentation" href="#" />
<link rel="top" title="Django Categories v1.0.5 documentation" href="#" />
<link rel="next" title="Installation" href="installation.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories 1.0.5 documentation</p>
<p>Django Categories v1.0.5 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Django Categories v 1.0</h1></div>
@ -147,7 +144,7 @@
<li class="toctree-l2"><a class="reference internal" href="reference/management_commands.html">Management Commands</a></li>
<li class="toctree-l2"><a class="reference internal" href="reference/models.html">Models</a></li>
<li class="toctree-l2"><a class="reference internal" href="reference/settings.html">Settings</a></li>
<li class="toctree-l2"><a class="reference internal" href="reference/templatetags.html">Template Tags</a></li>
<li class="toctree-l2"><a class="reference internal" href="reference/templatetags.html">Template tags and filters</a></li>
</ul>
</li>
</ul>
@ -170,7 +167,7 @@
<div class="footer">
<p>
&copy; Copyright 2010-2012, Corey Oordt.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.5.
</p>
</div>
<div class="clearer"></div>

View file

@ -2,16 +2,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Installation &mdash; Django Categories 1.0.5 documentation</title>
<title>Installation &mdash; Django Categories v1.0.5 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: '',
@ -24,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 1.0.5 documentation" href="index.html" />
<link rel="top" title="Django Categories v1.0.5 documentation" href="index.html" />
<link rel="next" title="Getting Started" href="getting_started.html" />
<link rel="prev" title="Django Categories v 1.0" href="index.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories 1.0.5 documentation</p>
<p>Django Categories v1.0.5 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Installation</h1></div>
@ -144,7 +141,7 @@
<div class="footer">
<p>
&copy; Copyright 2010-2012, Corey Oordt.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.5.
</p>
</div>
<div class="clearer"></div>

Binary file not shown.

View file

@ -2,16 +2,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Reference &mdash; Django Categories 1.0.5 documentation</title>
<title>Reference &mdash; Django Categories v1.0.5 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: '../',
@ -24,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 1.0.5 documentation" href="../index.html" />
<link rel="top" title="Django Categories v1.0.5 documentation" href="../index.html" />
<link rel="next" title="Management Commands" href="management_commands.html" />
<link rel="prev" title="Creating Custom Categories" href="../custom_categories.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories 1.0.5 documentation</p>
<p>Django Categories v1.0.5 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Reference</h1></div>
@ -58,7 +55,7 @@
<li class="toctree-l2"><a class="reference internal" href="management_commands.html">Management Commands</a></li>
<li class="toctree-l2"><a class="reference internal" href="models.html">Models</a></li>
<li class="toctree-l2"><a class="reference internal" href="settings.html">Settings</a></li>
<li class="toctree-l2"><a class="reference internal" href="templatetags.html">Template Tags</a></li>
<li class="toctree-l2"><a class="reference internal" href="templatetags.html">Template tags and filters</a></li>
</ul>
</li>
</ul>
@ -123,12 +120,10 @@
<li class="toctree-l2"><a class="reference internal" href="settings.html#javascript-url">JAVASCRIPT_URL</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="templatetags.html">Template Tags</a><ul>
<li class="toctree-l2"><a class="reference internal" href="templatetags.html#get-top-level-categories">get_top_level_categories</a></li>
<li class="toctree-l2"><a class="reference internal" href="templatetags.html#display-path-as-ul">display_path_as_ul</a></li>
<li class="toctree-l2"><a class="reference internal" href="templatetags.html#get-category-drilldown">get_category_drilldown</a></li>
<li class="toctree-l2"><a class="reference internal" href="templatetags.html#display-drilldown-as-ul">display_drilldown_as_ul</a></li>
<li class="toctree-l2"><a class="reference internal" href="templatetags.html#breadcrumbs-tag">breadcrumbs tag</a></li>
<li class="toctree-l1"><a class="reference internal" href="templatetags.html">Template tags and filters</a><ul>
<li class="toctree-l2"><a class="reference internal" href="templatetags.html#filters">Filters</a></li>
<li class="toctree-l2"><a class="reference internal" href="templatetags.html#inclusion-tags">Inclusion tags</a></li>
<li class="toctree-l2"><a class="reference internal" href="templatetags.html#template-tags">Template Tags</a></li>
</ul>
</li>
</ul>
@ -142,7 +137,7 @@
<div class="footer">
<p>
&copy; Copyright 2010-2012, Corey Oordt.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.5.
</p>
</div>
<div class="clearer"></div>

View file

@ -2,16 +2,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Management Commands &mdash; Django Categories 1.0.5 documentation</title>
<title>Management Commands &mdash; Django Categories v1.0.5 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: '../',
@ -24,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 1.0.5 documentation" href="../index.html" />
<link rel="top" title="Django Categories v1.0.5 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 1.0.5 documentation</p>
<p>Django Categories v1.0.5 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Management Commands</h1></div>
@ -59,7 +56,7 @@
<li class="toctree-l2 current"><a class="current reference internal" href="">Management Commands</a></li>
<li class="toctree-l2"><a class="reference internal" href="models.html">Models</a></li>
<li class="toctree-l2"><a class="reference internal" href="settings.html">Settings</a></li>
<li class="toctree-l2"><a class="reference internal" href="templatetags.html">Template Tags</a></li>
<li class="toctree-l2"><a class="reference internal" href="templatetags.html">Template tags and filters</a></li>
</ul>
</li>
</ul>
@ -124,7 +121,7 @@
<div class="footer">
<p>
&copy; Copyright 2010-2012, Corey Oordt.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.5.
</p>
</div>
<div class="clearer"></div>

View file

@ -2,16 +2,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Models &mdash; Django Categories 1.0.5 documentation</title>
<title>Models &mdash; Django Categories v1.0.5 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: '../',
@ -24,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 1.0.5 documentation" href="../index.html" />
<link rel="top" title="Django Categories v1.0.5 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 1.0.5 documentation</p>
<p>Django Categories v1.0.5 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Models</h1></div>
@ -59,7 +56,7 @@
<li class="toctree-l2"><a class="reference internal" href="management_commands.html">Management Commands</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="">Models</a></li>
<li class="toctree-l2"><a class="reference internal" href="settings.html">Settings</a></li>
<li class="toctree-l2"><a class="reference internal" href="templatetags.html">Template Tags</a></li>
<li class="toctree-l2"><a class="reference internal" href="templatetags.html">Template tags and filters</a></li>
</ul>
</li>
</ul>
@ -127,7 +124,7 @@
<dl class="attribute">
<dt id="CategoryBase.active">
<tt class="descname">active</tt><a class="headerlink" href="#CategoryBase.active" title="Permalink to this definition"></a></dt>
<dd><p><strong>Required</strong> <tt class="docutils literal"><span class="pre">BooleanField</span></tt> <em>default:</em> <tt class="docutils literal"><span class="pre">True</span></tt></p>
<dd><p><strong>Required</strong> <tt class="docutils literal"><span class="pre">BooleanField</span></tt> <em>default:</em> <tt class="xref docutils literal"><span class="pre">True</span></tt></p>
<p>Is this item active. If it is inactive, all children are set to inactive as well.</p>
</dd></dl>
@ -135,7 +132,7 @@
<dt id="CategoryBase.objects">
<tt class="descname">objects</tt><a class="headerlink" href="#CategoryBase.objects" title="Permalink to this definition"></a></dt>
<dd><p><tt class="docutils literal"><span class="pre">CategoryManager</span></tt></p>
<p>An object manager that adds an <tt class="docutils literal"><span class="pre">active</span></tt> method for only selecting items whose <tt class="docutils literal"><span class="pre">active</span></tt> attribute is <tt class="docutils literal"><span class="pre">True</span></tt>.</p>
<p>An object manager that adds an <tt class="docutils literal"><span class="pre">active</span></tt> method for only selecting items whose <tt class="docutils literal"><span class="pre">active</span></tt> attribute is <tt class="xref docutils literal"><span class="pre">True</span></tt>.</p>
</dd></dl>
<dl class="attribute">
@ -240,7 +237,7 @@
<div class="footer">
<p>
&copy; Copyright 2010-2012, Corey Oordt.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.5.
</p>
</div>
<div class="clearer"></div>

View file

@ -2,16 +2,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Settings &mdash; Django Categories 1.0.5 documentation</title>
<title>Settings &mdash; Django Categories v1.0.5 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: '../',
@ -24,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 1.0.5 documentation" href="../index.html" />
<link rel="top" title="Django Categories v1.0.5 documentation" href="../index.html" />
<link rel="up" title="Reference" href="index.html" />
<link rel="next" title="Template Tags" href="templatetags.html" />
<link rel="next" title="Template tags and filters" href="templatetags.html" />
<link rel="prev" title="Models" href="models.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories 1.0.5 documentation</p>
<p>Django Categories v1.0.5 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Settings</h1></div>
@ -39,7 +36,7 @@
<li id="toc_button"><div class="headerButton"><a href="#">Table of Contents</a></div></li>
<li id="page_buttons">
<div class="headerButton"><a href="../genindex.html" title="General Index" accesskey="I">index</a></div>
<div class="headerButton"><a href="templatetags.html" title="Template Tags" accesskey="N">next</a></div>
<div class="headerButton"><a href="templatetags.html" title="Template tags and filters" accesskey="N">next</a></div>
<div class="headerButton"><a href="models.html" title="Models" accesskey="P">previous</a></div>
</li>
</ul>
@ -59,7 +56,7 @@
<li class="toctree-l2"><a class="reference internal" href="management_commands.html">Management Commands</a></li>
<li class="toctree-l2"><a class="reference internal" href="models.html">Models</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="">Settings</a></li>
<li class="toctree-l2"><a class="reference internal" href="templatetags.html">Template Tags</a></li>
<li class="toctree-l2"><a class="reference internal" href="templatetags.html">Template tags and filters</a></li>
</ul>
</li>
</ul>
@ -128,8 +125,8 @@
</div>
<div class="section" id="allow-slug-change">
<span id="id1"></span><h2><a class="toc-backref" href="#id11">ALLOW_SLUG_CHANGE</a><a class="headerlink" href="#allow-slug-change" title="Permalink to this headline"></a></h2>
<p><strong>Default:</strong> <tt class="docutils literal"><span class="pre">False</span></tt></p>
<p><strong>Description:</strong> Changing the slug for a category can have serious consequences if it is used as part of a URL. Setting this to <tt class="docutils literal"><span class="pre">True</span></tt> will allow users to change the slug of a category.</p>
<p><strong>Default:</strong> <tt class="xref docutils literal"><span class="pre">False</span></tt></p>
<p><strong>Description:</strong> Changing the slug for a category can have serious consequences if it is used as part of a URL. Setting this to <tt class="xref docutils literal"><span class="pre">True</span></tt> will allow users to change the slug of a category.</p>
</div>
<div class="section" id="slug-transliterator">
<span id="id2"></span><h2><a class="toc-backref" href="#id12">SLUG_TRANSLITERATOR</a><a class="headerlink" href="#slug-transliterator" title="Permalink to this headline"></a></h2>
@ -159,7 +156,7 @@
</div>
<div class="section" id="register-admin">
<span id="thumbnail-upload-path"></span><span id="id7"></span><h2><a class="toc-backref" href="#id17">REGISTER_ADMIN</a><a class="headerlink" href="#register-admin" title="Permalink to this headline"></a></h2>
<p><strong>Default:</strong> <tt class="docutils literal"><span class="pre">True</span></tt></p>
<p><strong>Default:</strong> <tt class="xref docutils literal"><span class="pre">True</span></tt></p>
<p><strong>Description:</strong> If you write your own category class by subclassing <tt class="docutils literal"><span class="pre">CategoryBase</span></tt> then you probably have no use for registering the default <tt class="docutils literal"><span class="pre">Category</span></tt> class in the admin.</p>
</div>
<div class="section" id="id8">
@ -186,7 +183,7 @@
<div class="footer">
<p>
&copy; Copyright 2010-2012, Corey Oordt.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.5.
</p>
</div>
<div class="clearer"></div>

View file

@ -2,16 +2,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Template Tags &mdash; Django Categories 1.0.5 documentation</title>
<title>Template tags and filters &mdash; Django Categories v1.0.5 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: '../',
@ -24,16 +21,16 @@
<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 1.0.5 documentation" href="../index.html" />
<link rel="top" title="Django Categories v1.0.5 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 1.0.5 documentation</p>
<p>Django Categories v1.0.5 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Template Tags</h1></div>
<div id="title"><h1>Template tags and filters</h1></div>
<ul id="headerButtons">
<li id="toc_button"><div class="headerButton"><a href="#">Table of Contents</a></div></li>
<li id="page_buttons">
@ -57,7 +54,7 @@
<li class="toctree-l2"><a class="reference internal" href="management_commands.html">Management Commands</a></li>
<li class="toctree-l2"><a class="reference internal" href="models.html">Models</a></li>
<li class="toctree-l2"><a class="reference internal" href="settings.html">Settings</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="">Template Tags</a></li>
<li class="toctree-l2 current"><a class="current reference internal" href="">Template tags and filters</a></li>
</ul>
</li>
</ul>
@ -94,25 +91,128 @@
<div class="bodywrapper">
<div class="body">
<div class="section" id="template-tags">
<h1>Template Tags<a class="headerlink" href="#template-tags" title="Permalink to this headline"></a></h1>
<div class="section" id="get-top-level-categories">
<h2>get_top_level_categories<a class="headerlink" href="#get-top-level-categories" title="Permalink to this headline"></a></h2>
<p>Retrieves an alphabetical list of all the categories that have no parents.</p>
<p>Syntax:</p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">get_top_level_categories</span> <span class="k">as</span> <span class="nv">categories</span> <span class="cp">%}</span><span class="x"></span>
<div class="section" id="template-tags-and-filters">
<h1>Template tags and filters<a class="headerlink" href="#template-tags-and-filters" title="Permalink to this headline"></a></h1>
<div class="contents local topic" id="contents">
<ul class="simple">
<li><a class="reference internal" href="#filters" id="id2">Filters</a><ul>
<li><a class="reference internal" href="#category-path" id="id3"><tt class="docutils literal"><span class="pre">category_path</span></tt></a></li>
<li><a class="reference internal" href="#tree-info" id="id4"><tt class="docutils literal"><span class="pre">tree_info</span></tt></a></li>
<li><a class="reference internal" href="#tree-queryset" id="id5"><tt class="docutils literal"><span class="pre">tree_queryset</span></tt></a></li>
</ul>
</li>
<li><a class="reference internal" href="#inclusion-tags" id="id6">Inclusion tags</a><ul>
<li><a class="reference internal" href="#display-path-as-ul" id="id7"><tt class="docutils literal"><span class="pre">display_path_as_ul</span></tt></a></li>
<li><a class="reference internal" href="#display-drilldown-as-ul" id="id8"><tt class="docutils literal"><span class="pre">display_drilldown_as_ul</span></tt></a></li>
<li><a class="reference internal" href="#breadcrumbs-tag" id="id9"><tt class="docutils literal"><span class="pre">breadcrumbs</span> <span class="pre">tag</span></tt></a></li>
</ul>
</li>
<li><a class="reference internal" href="#template-tags" id="id10">Template Tags</a><ul>
<li><a class="reference internal" href="#get-top-level-categories" id="id11"><tt class="docutils literal"><span class="pre">get_top_level_categories</span></tt></a></li>
<li><a class="reference internal" href="#get-category-drilldown" id="id12"><tt class="docutils literal"><span class="pre">get_category_drilldown</span></tt></a></li>
<li><a class="reference internal" href="#recursetree" id="id13"><tt class="docutils literal"><span class="pre">recursetree</span></tt></a></li>
</ul>
</li>
</ul>
</div>
<div class="section" id="filters">
<h2><a class="toc-backref" href="#contents">Filters</a><a class="headerlink" href="#filters" title="Permalink to this headline"></a></h2>
<div class="section" id="category-path">
<h3><a class="toc-backref" href="#contents"><tt class="docutils literal"><span class="pre">category_path</span></tt></a><a class="headerlink" href="#category-path" title="Permalink to this headline"></a></h3>
<p><strong>Optional Parameter:</strong> separator string. <em>Default:</em> <tt class="docutils literal"><span class="pre">&quot;</span> <span class="pre">::</span> <span class="pre">&quot;</span></tt></p>
<p>Creates a path represented by a categories by joining the items with a separator.</p>
<p>Each path item will be coerced to unicode, so you can pass a list of category instances, if required.</p>
<p><strong>Example using a list of categories:</strong></p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{{</span> <span class="nv">some_list</span><span class="o">|</span><span class="nf">category_path</span> <span class="cp">}}</span><span class="x"></span>
</pre></div>
</div>
<p>Returns an list of categories <tt class="docutils literal"><span class="pre">[&lt;category&gt;,</span> <span class="pre">&lt;category&gt;,</span> <span class="pre">&lt;category,</span> <span class="pre">...]</span></tt></p>
<p>If <tt class="docutils literal"><span class="pre">some_list</span></tt> is <tt class="docutils literal"><span class="pre">[</span> <span class="pre">&lt;Category:</span> <span class="pre">Country&gt;,</span> <span class="pre">&lt;Category:</span> <span class="pre">Country</span> <span class="pre">pop&gt;,</span> <span class="pre">&lt;Category:</span> <span class="pre">Urban</span> <span class="pre">Cowboy&gt;]</span></tt> the result will be:</p>
<div class="highlight-python"><pre>Country :: Country pop :: Urban Cowboy</pre>
</div>
<p><strong>Example using a category node and optional separator parameter:</strong></p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{{</span> <span class="nv">some_node.get_ancestors</span><span class="o">|</span><span class="nf">category_path</span><span class="s2">:&quot; &gt; &quot;</span> <span class="cp">}}</span><span class="x"></span>
</pre></div>
</div>
<p>If <tt class="docutils literal"><span class="pre">some_node</span></tt> was category &#8220;Urban Cowboy&#8221;, the result will be:</p>
<div class="highlight-python"><pre>Country &gt; Country pop &gt; Urban Cowboy</pre>
</div>
</div>
<div class="section" id="tree-info">
<span id="id1"></span><h3><a class="toc-backref" href="#contents"><tt class="docutils literal"><span class="pre">tree_info</span></tt></a><a class="headerlink" href="#tree-info" title="Permalink to this headline"></a></h3>
<p><strong>Optional Parameter:</strong> <tt class="docutils literal"><span class="pre">&quot;ancestors&quot;</span></tt></p>
<p>Given a list of categories, it iterates over the list, generating a tuple of the current category and a dict containing information about the tree structure around it, with the following keys:</p>
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">'new_level'</span></tt></dt>
<dd><tt class="xref docutils literal"><span class="pre">True</span></tt> if the current item is the start of a new level in the tree, <tt class="xref docutils literal"><span class="pre">False</span></tt> otherwise.</dd>
<dt><tt class="docutils literal"><span class="pre">'closed_levels'</span></tt></dt>
<dd>A list of levels which end after the current item. This will be an empty list if the next category&#8217;s level is the same as or greater than the level of the current item.</dd>
</dl>
<p>Provide the optional argument, <tt class="docutils literal"><span class="pre">&quot;ancestors&quot;</span></tt>, to add a list of unicode representations of the ancestors of the current category, in descending order (root node first, immediate parent last), under the key &#8216;ancestors&#8217;.</p>
<p>For example: given the sample tree below, the contents of the list which would be available under the &#8216;ancestors&#8217; key are given on the right:</p>
<div class="highlight-python"><pre>Country -&gt; []
Country pop -&gt; [u'Country pop']
Urban Cowboy -&gt; [u'Country', u'Country pop']</pre>
</div>
<p>Using this filter with unpacking in a {% for %} tag, you should have enough information about the tree structure to create a hierarchical representation of the tree.</p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">for</span> <span class="nv">node</span><span class="o">,</span><span class="nv">structure</span> <span class="k">in</span> <span class="nv">objects</span><span class="o">|</span><span class="nf">tree_info</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">structure.new_level</span> <span class="cp">%}</span><span class="x">&lt;ul&gt;&lt;li&gt;</span><span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span><span class="x">&lt;/li&gt;&lt;li&gt;</span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{{</span> <span class="nv">node.name</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">level</span> <span class="k">in</span> <span class="nv">structure.closed_levels</span> <span class="cp">%}</span><span class="x">&lt;/li&gt;&lt;/ul&gt;</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">endfor</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
</div>
<div class="section" id="tree-queryset">
<h3><a class="toc-backref" href="#contents"><tt class="docutils literal"><span class="pre">tree_queryset</span></tt></a><a class="headerlink" href="#tree-queryset" title="Permalink to this headline"></a></h3>
<p>Convert a regular category <tt class="xref py py-class docutils literal"><span class="pre">QuerySet</span></tt> into a new, ordered <tt class="xref py py-class docutils literal"><span class="pre">QuerySet</span></tt> that includes the categories selected and their ancestors.</p>
<p>This is especially helpful when you have a subset of categories and want to show the hierarchy for all the items.</p>
<p>For example, if we add it to the example for <a class="reference internal" href="#tree-info"><em>tree_info</em></a>:</p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">for</span> <span class="nv">node</span><span class="o">,</span><span class="nv">structure</span> <span class="k">in</span> <span class="nv">objects</span><span class="o">|</span><span class="nf">tree_queryset</span><span class="o">|</span><span class="nf">tree_info</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">if</span> <span class="nv">structure.new_level</span> <span class="cp">%}</span><span class="x">&lt;ul&gt;&lt;li&gt;</span><span class="cp">{%</span> <span class="k">else</span> <span class="cp">%}</span><span class="x">&lt;/li&gt;&lt;li&gt;</span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{{</span> <span class="nv">node.name</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">level</span> <span class="k">in</span> <span class="nv">structure.closed_levels</span> <span class="cp">%}</span><span class="x">&lt;/li&gt;&lt;/ul&gt;</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">endfor</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
<p>A list of unrelated categories such as <tt class="docutils literal"><span class="pre">[&lt;Category:</span> <span class="pre">Urban</span> <span class="pre">cowboy&gt;,</span> <span class="pre">&lt;Category:</span> <span class="pre">Urban</span> <span class="pre">comtemporary&gt;]</span></tt>, the above template example will output the two categories and their ancestors:</p>
<div class="highlight-html"><div class="highlight"><pre><span class="nt">&lt;ul&gt;&lt;li&gt;</span>
Country
<span class="nt">&lt;ul&gt;&lt;li&gt;</span>
Country pop
<span class="nt">&lt;ul&gt;&lt;li&gt;</span>
Urban cowboy
<span class="nt">&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;</span>
<span class="nt">&lt;ul&gt;&lt;li&gt;</span>
Rhythm and blues
<span class="nt">&lt;ul&gt;&lt;li&gt;</span>
Urban contemporary
<span class="nt">&lt;/li&gt;&lt;/ul&gt;&lt;/li&gt;&lt;/ul&gt;</span>
</pre></div>
</div>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Categories that have similar ancestors are grouped accordingly. There is no duplication of the ancestor tree.</p>
</div>
</div>
</div>
<div class="section" id="inclusion-tags">
<h2><a class="toc-backref" href="#contents">Inclusion tags</a><a class="headerlink" href="#inclusion-tags" title="Permalink to this headline"></a></h2>
<div class="section" id="display-path-as-ul">
<h2>display_path_as_ul<a class="headerlink" href="#display-path-as-ul" title="Permalink to this headline"></a></h2>
<p>Render the category with ancestors, but no children using the <tt class="docutils literal"><span class="pre">categories/ul_tree.html</span></tt> template.</p>
<p>Example:</p>
<h3><a class="toc-backref" href="#contents"><tt class="docutils literal"><span class="pre">display_path_as_ul</span></tt></a><a class="headerlink" href="#display-path-as-ul" title="Permalink to this headline"></a></h3>
<p><strong>Template Rendered:</strong> <tt class="docutils literal"><span class="pre">categories/ul_tree.html</span></tt></p>
<p><strong>Syntax 1:</strong> <tt class="docutils literal"><span class="pre">{%</span> <span class="pre">display_path_as_ul</span> <span class="pre">&lt;category_obj&gt;</span> <span class="pre">%}</span></tt></p>
<p><strong>Syntax 2:</strong> <tt class="docutils literal"><span class="pre">{%</span> <span class="pre">display_path_as_ul</span> <span class="pre">&lt;path_string&gt;[</span> <span class="pre">using=&quot;app.Model&quot;]</span> <span class="pre">%}</span></tt></p>
<p>Render the category with ancestors, but no children.</p>
<p>Pass either an object that subclasses <a class="reference internal" href="models.html#CategoryBase" title="CategoryBase"><tt class="xref py py-class docutils literal"><span class="pre">CategoryBase</span></tt></a> or a path string for the category. Add <tt class="docutils literal"><span class="pre">using=&quot;app.Model&quot;</span></tt> to specify which model when using a path string. The default model used is <a class="reference internal" href="models.html#Category" title="Category"><tt class="xref py py-class docutils literal"><span class="pre">Category</span></tt></a>.</p>
<p><strong>Example, using Category model:</strong></p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">display_path_as_ul</span> <span class="s2">&quot;/Grandparent/Parent&quot;</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
<p>or</p>
<p><strong>Example, using custom model:</strong></p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">display_path_as_ul</span> <span class="s2">&quot;/Grandparent/Parent&quot;</span> <span class="nv">using</span><span class="o">=</span><span class="s2">&quot;coolapp.MusicGenre&quot;</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
<p><strong>Example, using an object:</strong></p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">display_path_as_ul</span> <span class="nv">category_obj</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
@ -127,31 +227,21 @@
</pre></div>
</div>
</div>
<div class="section" id="get-category-drilldown">
<h2>get_category_drilldown<a class="headerlink" href="#get-category-drilldown" title="Permalink to this headline"></a></h2>
<p>Retrieves the specified category, its ancestors and its immediate children
as an iterable.</p>
<p>Example:</p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">get_category_drilldown</span> <span class="s2">&quot;/Grandparent/Parent&quot;</span> <span class="k">as</span> <span class="nv">family</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
<p>or</p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">get_category_drilldown</span> <span class="nv">category_obj</span> <span class="k">as</span> <span class="nv">family</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
<p>Sets <tt class="docutils literal"><span class="pre">family</span></tt> to:</p>
<div class="highlight-python"><pre>[Grandparent, Parent, Child 1, Child 2, Child n]</pre>
</div>
</div>
<div class="section" id="display-drilldown-as-ul">
<h2>display_drilldown_as_ul<a class="headerlink" href="#display-drilldown-as-ul" title="Permalink to this headline"></a></h2>
<p>Render the category with ancestors and children using the
<tt class="docutils literal"><span class="pre">categories/ul_tree.html</span></tt> template.</p>
<p>Example:</p>
<h3><a class="toc-backref" href="#contents"><tt class="docutils literal"><span class="pre">display_drilldown_as_ul</span></tt></a><a class="headerlink" href="#display-drilldown-as-ul" title="Permalink to this headline"></a></h3>
<p><strong>Template rendered:</strong> <tt class="docutils literal"><span class="pre">categories/ul_tree.html</span></tt></p>
<p><strong>Syntax 1:</strong> <tt class="docutils literal"><span class="pre">{%</span> <span class="pre">display_drilldown_as_ul</span> <span class="pre">category_obj</span> <span class="pre">%}</span></tt></p>
<p><strong>Syntax 2:</strong> <tt class="docutils literal"><span class="pre">{%</span> <span class="pre">display_drilldown_as_ul</span> <span class="pre">&quot;/Grandparent/Parent&quot;</span> <span class="pre">[using=&quot;app.Model&quot;]</span> <span class="pre">%}</span></tt></p>
<p>Render the category with ancestors and children.</p>
<p><strong>Example, using Category model:</strong></p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">display_drilldown_as_ul</span> <span class="s2">&quot;/Grandparent/Parent&quot;</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
<p>or:</p>
<p><strong>Example, using custom model:</strong></p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">display_drilldown_as_ul</span> <span class="s2">&quot;/Grandparent/Parent&quot;</span> <span class="nv">using</span><span class="o">=</span><span class="s2">&quot;coolapp.MusicGenre&quot;</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
<p><strong>Example, using an object:</strong></p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">display_drilldown_as_ul</span> <span class="nv">category_obj</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
@ -177,13 +267,20 @@ as an iterable.</p>
</div>
</div>
<div class="section" id="breadcrumbs-tag">
<h2>breadcrumbs tag<a class="headerlink" href="#breadcrumbs-tag" title="Permalink to this headline"></a></h2>
<p>Render breadcrumbs, using the <tt class="docutils literal"><span class="pre">categories/breadcrumbs.html</span></tt> template, using the optional <tt class="docutils literal"><span class="pre">separator</span></tt> argument.</p>
<p>Example:</p>
<h3><a class="toc-backref" href="#contents"><tt class="docutils literal"><span class="pre">breadcrumbs</span> <span class="pre">tag</span></tt></a><a class="headerlink" href="#breadcrumbs-tag" title="Permalink to this headline"></a></h3>
<p><strong>Template rendered:</strong> <tt class="docutils literal"><span class="pre">categories/breadcrumbs.html</span></tt></p>
<p><strong>Syntax 1:</strong> <tt class="docutils literal"><span class="pre">{%</span> <span class="pre">breadcrumbs</span> <span class="pre">category_obj</span> <span class="pre">[separator=&quot;</span> <span class="pre">::</span> <span class="pre">&quot;]</span> <span class="pre">%}</span></tt></p>
<p><strong>Syntax 2:</strong> <tt class="docutils literal"><span class="pre">{%</span> <span class="pre">breadcrumbs</span> <span class="pre">&quot;/Grandparent/Parent&quot;</span> <span class="pre">[separator=&quot;</span> <span class="pre">::</span> <span class="pre">&quot;]</span> <span class="pre">[using=&quot;app.Model&quot;]</span> <span class="pre">%}</span></tt></p>
<p>Render breadcrumbs for the given path using <tt class="docutils literal"><span class="pre">::</span></tt> or the given separator.</p>
<p><strong>Example using Category model:</strong></p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">breadcrumbs</span> <span class="s2">&quot;/Grandparent/Parent&quot;</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
<p>or:</p>
<p><strong>Example using a custom model:</strong></p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">breadcrumbs</span> <span class="s2">&quot;/Grandparent/Parent&quot;</span> <span class="nv">using</span><span class="o">=</span><span class="s2">&quot;coolapp.MusicGenre&quot;</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
<p><strong>Example using an object:</strong></p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">breadcrumbs</span> <span class="nv">category_obj</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
@ -191,15 +288,87 @@ as an iterable.</p>
<div class="highlight-html"><div class="highlight"><pre><span class="nt">&lt;a</span> <span class="na">href=</span><span class="s">&quot;/categories/grandparent/&quot;</span><span class="nt">&gt;</span>Grandparent<span class="nt">&lt;/a&gt;</span> / Parent
</pre></div>
</div>
<p>You can alter the separator used in the template by adding a string argument to be the separator:</p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">breadcrumbs</span> <span class="nv">category_obj</span> <span class="s2">&quot;::&quot;</span> <span class="cp">%}</span><span class="x"></span>
<p>You can alter the separator used in the template by adding a separator argument:</p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">breadcrumbs</span> <span class="nv">category_obj</span> <span class="nv">separator</span><span class="o">=</span><span class="s2">&quot; &amp;gt; &quot;</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
<p>Returns:</p>
<div class="highlight-html"><div class="highlight"><pre><span class="nt">&lt;a</span> <span class="na">href=</span><span class="s">&quot;/categories/grandparent/&quot;</span><span class="nt">&gt;</span>Grandparent<span class="nt">&lt;/a&gt;</span> :: Parent
<div class="highlight-html"><div class="highlight"><pre><span class="nt">&lt;a</span> <span class="na">href=</span><span class="s">&quot;/categories/grandparent/&quot;</span><span class="nt">&gt;</span>Grandparent<span class="nt">&lt;/a&gt;</span> <span class="ni">&amp;gt;</span> Parent
</pre></div>
</div>
</div>
</div>
<div class="section" id="template-tags">
<h2><a class="toc-backref" href="#contents">Template Tags</a><a class="headerlink" href="#template-tags" title="Permalink to this headline"></a></h2>
<div class="section" id="get-top-level-categories">
<h3><a class="toc-backref" href="#contents"><tt class="docutils literal"><span class="pre">get_top_level_categories</span></tt></a><a class="headerlink" href="#get-top-level-categories" title="Permalink to this headline"></a></h3>
<p>Retrieves an alphabetical list of all the categories that have no parents.</p>
<p>Syntax:</p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">get_top_level_categories</span> <span class="o">[</span><span class="nv">using</span> <span class="s2">&quot;app.Model&quot;</span><span class="o">]</span> <span class="k">as</span> <span class="nv">categories</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
<p>Returns an list of categories <tt class="docutils literal"><span class="pre">[&lt;category&gt;,</span> <span class="pre">&lt;category&gt;,</span> <span class="pre">&lt;category,</span> <span class="pre">...]</span></tt></p>
</div>
<div class="section" id="get-category-drilldown">
<h3><a class="toc-backref" href="#contents"><tt class="docutils literal"><span class="pre">get_category_drilldown</span></tt></a><a class="headerlink" href="#get-category-drilldown" title="Permalink to this headline"></a></h3>
<p><strong>Syntax 1:</strong> <tt class="docutils literal"><span class="pre">{%</span> <span class="pre">get_category_drilldown</span> <span class="pre">&lt;path_string&gt;</span> <span class="pre">[using</span> <span class="pre">&quot;app.Model&quot;]</span> <span class="pre">as</span> <span class="pre">&lt;varname&gt;</span> <span class="pre">%}</span></tt></p>
<p><strong>Syntax 2:</strong> <tt class="docutils literal"><span class="pre">{%</span> <span class="pre">get_category_drilldown</span> <span class="pre">&lt;object&gt;</span> <span class="pre">as</span> <span class="pre">&lt;varname&gt;</span> <span class="pre">%}</span></tt></p>
<p>Retrieves the specified category, its ancestors and its immediate children as an iterable. Syntax 1 allows for the retrieval of the category object via a slash-delimited path. The optional <tt class="docutils literal"><span class="pre">using</span> <span class="pre">&quot;app.Model&quot;</span></tt> allows you to specify from which model to retrieve the object.</p>
<p>Example:</p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">get_category_drilldown</span> <span class="s2">&quot;/Grandparent/Parent&quot;</span> <span class="nv">using</span> <span class="s2">&quot;family.Member&quot;</span> <span class="k">as</span> <span class="nv">family</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
<p>The second syntax uses an instance of any object that subclasses <a class="reference internal" href="models.html#CategoryBase" title="CategoryBase"><tt class="xref py py-class docutils literal"><span class="pre">CategoryBase</span></tt></a></p>
<div class="highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">get_category_drilldown</span> <span class="nv">category_obj</span> <span class="k">as</span> <span class="nv">family</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
<p>Both examples sets <tt class="docutils literal"><span class="pre">family</span></tt> to:</p>
<div class="highlight-python"><pre>[Grandparent, Parent, Child 1, Child 2, Child n]</pre>
</div>
</div>
<div class="section" id="recursetree">
<h3><a class="toc-backref" href="#contents"><tt class="docutils literal"><span class="pre">recursetree</span></tt></a><a class="headerlink" href="#recursetree" title="Permalink to this headline"></a></h3>
<p>This tag renders a section of your template recursively for each node in your
tree.</p>
<p>For example:</p>
<div class="highlight-django"><div class="highlight"><pre><span class="x">&lt;ul class=&quot;root&quot;&gt;</span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">recursetree</span> <span class="nv">nodes</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> &lt;li&gt;</span>
<span class="x"> </span><span class="cp">{{</span> <span class="nv">node.name</span> <span class="cp">}}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">if</span> <span class="k">not</span> <span class="nv">node.is_leaf_node</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> &lt;ul class=&quot;children&quot;&gt;</span>
<span class="x"> </span><span class="cp">{{</span> <span class="nv">children</span> <span class="cp">}}</span><span class="x"></span>
<span class="x"> &lt;/ul&gt;</span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endif</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> &lt;/li&gt;</span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endrecursetree</span> <span class="cp">%}</span><span class="x"></span>
<span class="x">&lt;/ul&gt;</span>
</pre></div>
</div>
<p>Note the special variables <tt class="docutils literal"><span class="pre">node</span></tt> and <tt class="docutils literal"><span class="pre">children</span></tt>.
These are magically inserted into your context while you&#8217;re inside the
<tt class="docutils literal"><span class="pre">recursetree</span></tt> tag.</p>
<blockquote>
<p><tt class="docutils literal"><span class="pre">node</span></tt> is an instance of your MPTT model.</p>
<p><tt class="docutils literal"><span class="pre">children</span></tt> : This variable holds the rendered HTML for the children of
<tt class="docutils literal"><span class="pre">node</span></tt>.</p>
</blockquote>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p>If you already have variables called <tt class="docutils literal"><span class="pre">node</span></tt> or <tt class="docutils literal"><span class="pre">children</span></tt> in your
template, and you need to access them inside the <tt class="docutils literal"><span class="pre">recursetree</span></tt> block,
you&#8217;ll need to alias them to some other name first:</p>
<div class="last highlight-django"><div class="highlight"><pre><span class="cp">{%</span> <span class="k">with</span> <span class="nv">node</span> <span class="k">as</span> <span class="nv">friendly_node</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">recursetree</span> <span class="nv">nodes</span> <span class="cp">%}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{{</span> <span class="nv">node.name</span> <span class="cp">}}</span><span class="x"> is friends with </span><span class="cp">{{</span> <span class="nv">friendly_node.name</span> <span class="cp">}}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{{</span> <span class="nv">children</span> <span class="cp">}}</span><span class="x"></span>
<span class="x"> </span><span class="cp">{%</span> <span class="k">endrecursetree</span> <span class="cp">%}</span><span class="x"></span>
<span class="cp">{%</span> <span class="k">endwith</span> <span class="cp">%}</span><span class="x"></span>
</pre></div>
</div>
</div>
</div>
</div>
</div>
@ -209,14 +378,14 @@ as an iterable.</p>
<div class="footer">
<p>
&copy; Copyright 2010-2012, Corey Oordt.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.5.
</p>
</div>
<div class="clearer"></div>
</div>
<div id="breadcrumbs">
<a href="index.html" accesskey="U">Reference</a><img src="../_static/triangle_closed.png" height="9" width="9" alt="&gt;">
Template Tags
Template tags and filters
</ul>
</div>
<script type="text/javascript" charset="utf-8" src="../_static/toc.js"></script>

View file

@ -2,16 +2,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registering Models &mdash; Django Categories 1.0.5 documentation</title>
<title>Registering Models &mdash; Django Categories v1.0.5 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: '',
@ -24,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 1.0.5 documentation" href="index.html" />
<link rel="top" title="Django Categories v1.0.5 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 1.0.5 documentation</p>
<p>Django Categories v1.0.5 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Registering Models</h1></div>
@ -178,7 +175,7 @@
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>model</strong> &#8211; The Django Model to link to Django Categories</li>
<li><strong>field_name</strong> &#8211; Optional name for the field <strong>default:</strong> category</li>
<li><strong>extra_params</strong> &#8211; Optional dictionary of extra parameters passed to the <tt class="docutils literal"><span class="pre">ForeignKey</span></tt> class.</li>
@ -212,7 +209,7 @@
<col class="field-name" />
<col class="field-body" />
<tbody valign="top">
<tr class="field-odd field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<tr class="field"><th class="field-name">Parameters:</th><td class="field-body"><ul class="first last simple">
<li><strong>model</strong> &#8211; The Django Model to link to Django Categories</li>
<li><strong>field_name</strong> &#8211; Optional name for the field <strong>default:</strong> categories</li>
<li><strong>extra_params</strong> &#8211; Optional dictionary of extra parameters passed to the <tt class="docutils literal"><span class="pre">ManyToManyField</span></tt> class.</li>
@ -238,7 +235,7 @@
<div class="footer">
<p>
&copy; Copyright 2010-2012, Corey Oordt.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.5.
</p>
</div>
<div class="clearer"></div>

View file

@ -2,16 +2,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Search &mdash; Django Categories 1.0.5 documentation</title>
<title>Search &mdash; Django Categories v1.0.5 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: '',
@ -25,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 1.0.5 documentation" href="index.html" />
<link rel="top" title="Django Categories v1.0.5 documentation" href="index.html" />
<script type="text/javascript">
jQuery(function() { Search.loadIndex("searchindex.js"); });
</script>
@ -34,7 +31,7 @@
</head>
<body>
<div id="docstitle">
<p>Django Categories 1.0.5 documentation</p>
<p>Django Categories v1.0.5 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Search</h1></div>
@ -99,7 +96,7 @@
<div class="footer">
<p>
&copy; Copyright 2010-2012, Corey Oordt.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.5.
</p>
</div>
<div class="clearer"></div>

File diff suppressed because one or more lines are too long

View file

@ -2,16 +2,13 @@
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Using categories in templates &mdash; Django Categories 1.0.5 documentation</title>
<title>Using categories in templates &mdash; Django Categories v1.0.5 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: '',
@ -24,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 1.0.5 documentation" href="index.html" />
<link rel="top" title="Django Categories v1.0.5 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 1.0.5 documentation</p>
<p>Django Categories v1.0.5 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Using categories in templates</h1></div>
@ -170,21 +167,21 @@ two-tuples of the current tree item and a <tt class="docutils literal"><span cla
information about the tree structure around the item, with the following
keys:</p>
<blockquote>
<div><dl class="docutils">
<dl class="docutils">
<dt><tt class="docutils literal"><span class="pre">'new_level'</span></tt></dt>
<dd><tt class="docutils literal"><span class="pre">True</span></tt> if the current item is the start of a new level in
the tree, <tt class="docutils literal"><span class="pre">False</span></tt> otherwise.</dd>
<dd><tt class="xref docutils literal"><span class="pre">True</span></tt> if the current item is the start of a new level in
the tree, <tt class="xref docutils literal"><span class="pre">False</span></tt> otherwise.</dd>
<dt><tt class="docutils literal"><span class="pre">'closed_levels'</span></tt></dt>
<dd>A list of levels which end after the current item. This will
be an empty list if the next item&#8217;s level is the same as or
greater than the level of the current item.</dd>
</dl>
</div></blockquote>
</blockquote>
<p>An optional argument can be provided to specify extra details about the
structure which should appear in the <tt class="docutils literal"><span class="pre">dict</span></tt>. This should be a
comma-separated list of feature names. The valid feature names are:</p>
<blockquote>
<div><dl class="docutils">
<dl class="docutils">
<dt>ancestors</dt>
<dd><p class="first">Adds a list of unicode representations of the ancestors of the
current node, in descending order (root node first, immediate
@ -198,7 +195,7 @@ on the right:</p>
</div>
</dd>
</dl>
</div></blockquote>
</blockquote>
</div>
</div>
</div>
@ -210,7 +207,7 @@ on the right:</p>
<div class="footer">
<p>
&copy; Copyright 2010-2012, Corey Oordt.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.1.2.
Created using <a href="http://sphinx.pocoo.org/">Sphinx</a> 1.0.5.
</p>
</div>
<div class="clearer"></div>