Updated docs.

This commit is contained in:
Corey Oordt 2011-05-16 08:58:37 -04:00
parent fa2b680c14
commit 441dbcde74
20 changed files with 319 additions and 75 deletions

View file

@ -17,6 +17,9 @@ New in 0.6
**Optional Thumbnail field**
Have a thumbnail for each category!
**"Categorize" models in settings**
Now you don't have to modify the model to add a ``Category`` relationship. Use the new settings to "wire" categories to different models.
Features of the project
=======================

View file

@ -37,9 +37,4 @@ Connecting your model with Django-Categories
Because there are a few additional methods and attributes that your model needs, you can't simply create a ``ForeignKey`` to ``Category``, even though that is eventually what happens.
You add a many-to-one or many-to-many relationship with Django Categories using the :py:func:`register_fk` and :py:func:`register_m2m` methods respectively. For example, if you added in your ``models.py``::
import categories
categories.register_fk(MyModel)
``MyModel`` would have a ``ForeignKey`` named ``category``
You add a many-to-one or many-to-many relationship with Django Categories using the ``CATEGORIES_SETTINGS['FK_REGISTRY']`` and ``CATEGORIES_SETTINGS['M2M_REGISTRY']`` settings respectively. For more information see :ref:`registering_models`\ .

View file

@ -1,3 +1,70 @@
.. _reference_settings:
========
Settings
========
The ``CATEGORIES_SETTINGS`` dictionary is where you can override the default settings. You don't have to include all the settings; only the ones which you want to override.
The default settings are:
.. code-block:: python
CATEGORIES_SETTINGS = {
'ALLOW_SLUG_CHANGE': False,
'CACHE_VIEW_LENGTH': 0,
'RELATION_MODELS': [],
'M2M_REGISTRY': {},
'FK_REGISTRY': {},
'THUMBNAIL_UPLOAD_PATH': 'uploads/categories/thumbnails',
'THUMBNAIL_STORAGE': settings.DEFAULT_FILE_STORAGE,
}
ALLOW_SLUG_CHANGE
=================
**Default:** ``False``
**Description:** Changing the slug for a category can have serious consequences if it is used as part of a URL. Setting this to ``True`` will allow users to change the slug of a category.
CACHE_VIEW_LENGTH
=================
**Default:** ``0``
**Description:** This setting will be deprecated soon, but in the mean time, it allows you to specify the amount of time each view result is cached.
RELATION_MODELS
===============
**Default:** ``[]``
**Description:** Relation models is a set of models that a user can associate with this category. You specify models using ``'app_name.modelname'`` syntax.
M2M_REGISTRY
============
**Default:** {}
**Description:** A dictionary where the keys are in ``'app_name.model_name'`` syntax, and the values are a string, dict, or tuple of dicts. See :ref:`registering_models`\ .
FK_REGISTRY
============
**Default:** {}
**Description:** A dictionary where the keys are in ``'app_name.model_name'`` syntax, and the values are a string, dict, or tuple of dicts. See :ref:`registering_models`\ .
THUMBNAIL_UPLOAD_PATH
=====================
**Default:** ``'uploads/categories/thumbnails'``
**Description:** Where thumbnails for the categories will be saved.
THUMBNAIL_STORAGE
=================
**Default:** ``settings.DEFAULT_FILE_STORAGE``
**Description:** How to store the thumbnails. Allows for external storage engines like S3.

View file

@ -1,3 +1,5 @@
.. _registering_models:
==================
Registering Models
==================
@ -18,7 +20,7 @@ It is nice to not have to modify the code of applications to add a relation to c
{'name': 'secondary_category', 'related_name': 'mymodel_sec_cat'}, )
},
'M2M_REGISTRY': {
'app.AModel': 'categories',
'app.BModel': 'categories',
'app.MyModel': ('other_categories', 'more_categories', ),
}
}
@ -86,7 +88,10 @@ Registering one or more Many-to-Many Category fields to a Model
CATEGORIES_SETTINGS = {
'M2M_REGISTRY': {
'app.AModel': 'categories',
'app.MyModel': ('other_categories', 'more_categories', ),
'app.MyModel': (
{'name': 'other_categories', 'related_name': 'other_cats'},
{'name': 'more_categories', 'related_name': 'more_cats'},
),
}
}

View file

@ -1,4 +1,4 @@
# Sphinx build info version 1
# This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done.
config: 071e7273e6f47dab6004e15916a31efa
config: 0f579989dd4cbe4af0af63fb63e64641
tags: fbb0d17656682115ca4d033fb2f83ba1

View file

@ -37,9 +37,4 @@ Connecting your model with Django-Categories
Because there are a few additional methods and attributes that your model needs, you can't simply create a ``ForeignKey`` to ``Category``, even though that is eventually what happens.
You add a many-to-one or many-to-many relationship with Django Categories using the :py:func:`register_fk` and :py:func:`register_m2m` methods respectively. For example, if you added in your ``models.py``::
import categories
categories.register_fk(MyModel)
``MyModel`` would have a ``ForeignKey`` named ``category``
You add a many-to-one or many-to-many relationship with Django Categories using the ``CATEGORIES_SETTINGS['FK_REGISTRY']`` and ``CATEGORIES_SETTINGS['M2M_REGISTRY']`` settings respectively. For more information see :ref:`registering_models`\ .

View file

@ -1,3 +1,70 @@
.. _reference_settings:
========
Settings
========
The ``CATEGORIES_SETTINGS`` dictionary is where you can override the default settings. You don't have to include all the settings; only the ones which you want to override.
The default settings are:
.. code-block:: python
CATEGORIES_SETTINGS = {
'ALLOW_SLUG_CHANGE': False,
'CACHE_VIEW_LENGTH': 0,
'RELATION_MODELS': [],
'M2M_REGISTRY': [],
'FK_REGISTRY': [],
'THUMBNAIL_UPLOAD_PATH': 'uploads/categories/thumbnails',
'THUMBNAIL_STORAGE': settings.DEFAULT_FILE_STORAGE,
}
ALLOW_SLUG_CHANGE
=================
**Default:** ``False``
**Description:** Changing the slug for a category can have serious consequences if it is used as part of a URL. Setting this to ``True`` will allow users to change the slug of a category.
CACHE_VIEW_LENGTH
=================
**Default:** ``0``
**Description:** This setting will be deprecated soon, but in the mean time, it allows you to specify the amount of time each view result is cached.
RELATION_MODELS
===============
**Default:** ``[]``
**Description:** Relation models is a set of models that a user can associate with this category. You specify models using ``'app_name.modelname'`` syntax.
M2M_REGISTRY
============
**Default:** {}
**Description:** A dictionary where the keys are in ``'app_name.model_name'`` syntax, and the values are a string, dict, or tuple of dicts. See :ref:`registering_models`\ .
FK_REGISTRY
============
**Default:** {}
**Description:** A dictionary where the keys are in ``'app_name.model_name'`` syntax, and the values are a string, dict, or tuple of dicts. See :ref:`registering_models`\ .
THUMBNAIL_UPLOAD_PATH
=====================
**Default:** ``'uploads/categories/thumbnails'``
**Description:** Where thumbnails for the categories will be saved.
THUMBNAIL_STORAGE
=================
**Default:** ``settings.DEFAULT_FILE_STORAGE``
**Description:** How to store the thumbnails. Allows for external storage engines like S3.

View file

@ -1,3 +1,5 @@
.. _registering_models:
==================
Registering Models
==================
@ -18,7 +20,7 @@ It is nice to not have to modify the code of applications to add a relation to c
{'name': 'secondary_category', 'related_name': 'mymodel_sec_cat'}, )
},
'M2M_REGISTRY': {
'app.AModel': 'categories',
'app.BModel': 'categories',
'app.MyModel': ('other_categories', 'more_categories', ),
}
}
@ -28,8 +30,8 @@ The ``FK_REGISTRY`` is a dictionary whose keys are the model to which to add the
The ``M2M_REGISTRY`` is a dictionary whose keys are the model to which to add the new field(s). The value is a string or tuple of strings specifying the necessary information for each field.
Registering One Category Field
******************************
Registering one Category field to model
***************************************
The simplest way is to specify the name of the field, such as:
@ -48,7 +50,7 @@ This is equivalent to adding the following the ``AModel`` of ``app``\ :
category = models.ForeignKey(Category)
If you want more control over the new field, you can use a dictionary and pass other ``ForeignKey`` options:
If you want more control over the new field, you can use a dictionary and pass other ``ForeignKey`` options. The ``name`` key is required:
.. code-block:: python
@ -61,9 +63,37 @@ If you want more control over the new field, you can use a dictionary and pass o
This is equivalent to adding the following the ``AModel`` of ``app``\ :
.. code-block:: python
category = models.ForeignKey(Category, related_name='amodel_cats')
Registering two or more Category fields to a Model
**************************************************
When you want more than one relation to ``Category``\ , all but one of the fields must specify a ``related_name`` to avoid conflicts, like so:
.. code-block:: python
CATEGORIES_SETTINGS = {
'FK_REGISTRY': {
'app.MyModel': (
'primary_category',
{'name': 'secondary_category', 'related_name': 'mymodel_sec_cat'}, )
},
Registering one or more Many-to-Many Category fields to a Model
***************************************************************
.. code-block:: python
CATEGORIES_SETTINGS = {
'M2M_REGISTRY': {
'app.AModel': 'categories',
'app.MyModel': (
{'name': 'other_categories', 'related_name': 'other_cats'},
{'name': 'more_categories', 'related_name': 'more_cats'},
),
}
}
Registering a many-to-one relationship
======================================

View file

@ -5,14 +5,14 @@ Template Tags
get_top_level_categories
========================
Retrieves an alphabetical list of all the categories.
Retrieves an alphabetical list of all the categories that have no parents.
Syntax:
.. code-block:: django
{% get_top_level_categories as categories %}
Returns an list of categories ``[<category>, <category>, <category, ...]``
@ -72,7 +72,7 @@ Sets ``family`` to::
display_drilldown_as_ul
=======================
Render the category with ancestors, but no children using the
Render the category with ancestors and children using the
``categories/ul_tree.html`` template.
Example:

View file

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

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Getting Started &mdash; Django Categories v0.6beta1 documentation</title>
<title>Getting Started &mdash; Django Categories v0.6 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.6beta1',
VERSION: '0.6',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,13 +21,13 @@
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.6beta1 documentation" href="index.html" />
<link rel="top" title="Django Categories v0.6 documentation" href="index.html" />
<link rel="next" title="Using categories in templates" href="usage.html" />
<link rel="prev" title="Django Categories v|version| documentation!" href="index.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.6beta1 documentation</p>
<p>Django Categories v0.6 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Getting Started</h1></div>
@ -52,6 +52,7 @@
<li class="toctree-l1"><a class="reference internal" href="usage.html">Using categories in templates</a></li>
<li class="toctree-l1"><a class="reference internal" href="registering_models.html">Registering Models</a></li>
<li class="toctree-l1"><a class="reference internal" href="templatetags.html">Template Tags</a></li>
<li class="toctree-l1"><a class="reference internal" href="reference/index.html">Reference</a></li>
</ul>
<h3>This Page</h3>
@ -121,12 +122,7 @@ Model 2
<div class="section" id="connecting-your-model-with-django-categories">
<h2>Connecting your model with Django-Categories<a class="headerlink" href="#connecting-your-model-with-django-categories" title="Permalink to this headline"></a></h2>
<p>Because there are a few additional methods and attributes that your model needs, you can&#8217;t simply create a <tt class="docutils literal"><span class="pre">ForeignKey</span></tt> to <tt class="docutils literal"><span class="pre">Category</span></tt>, even though that is eventually what happens.</p>
<p>You add a many-to-one or many-to-many relationship with Django Categories using the <a class="reference internal" href="registering_models.html#register_fk" title="register_fk"><tt class="xref py py-func docutils literal"><span class="pre">register_fk()</span></tt></a> and <a class="reference internal" href="registering_models.html#register_m2m" title="register_m2m"><tt class="xref py py-func docutils literal"><span class="pre">register_m2m()</span></tt></a> methods respectively. For example, if you added in your <tt class="docutils literal"><span class="pre">models.py</span></tt>:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="kn">import</span> <span class="nn">categories</span>
<span class="n">categories</span><span class="o">.</span><span class="n">register_fk</span><span class="p">(</span><span class="n">MyModel</span><span class="p">)</span>
</pre></div>
</div>
<p><tt class="docutils literal"><span class="pre">MyModel</span></tt> would have a <tt class="docutils literal"><span class="pre">ForeignKey</span></tt> named <tt class="docutils literal"><span class="pre">category</span></tt></p>
<p>You add a many-to-one or many-to-many relationship with Django Categories using the <tt class="docutils literal"><span class="pre">CATEGORIES_SETTINGS['FK_REGISTRY']</span></tt> and <tt class="docutils literal"><span class="pre">CATEGORIES_SETTINGS['M2M_REGISTRY']</span></tt> settings respectively. For more information see <a class="reference internal" href="registering_models.html#registering-models"><em>Registering Models</em></a>.</p>
</div>
</div>

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Django Categories v|version| documentation! &mdash; Django Categories v0.6beta1 documentation</title>
<title>Django Categories v|version| documentation! &mdash; Django Categories v0.6 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.6beta1',
VERSION: '0.6',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,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 v0.6beta1 documentation" href="#" />
<link rel="top" title="Django Categories v0.6 documentation" href="#" />
<link rel="next" title="Getting Started" href="getting_started.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.6beta1 documentation</p>
<p>Django Categories v0.6 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Django Categories v|version| documentation!</h1></div>

Binary file not shown.

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Reference &mdash; Django Categories v0.6beta1 documentation</title>
<title>Reference &mdash; Django Categories v0.6 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.6beta1',
VERSION: '0.6',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,13 +21,13 @@
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.6beta1 documentation" href="../index.html" />
<link rel="top" title="Django Categories v0.6 documentation" href="../index.html" />
<link rel="next" title="Settings" href="settings.html" />
<link rel="prev" title="Template Tags" href="../templatetags.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.6beta1 documentation</p>
<p>Django Categories v0.6 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Reference</h1></div>
@ -91,7 +91,16 @@
<h1>Reference<a class="headerlink" href="#reference" title="Permalink to this headline"></a></h1>
<div class="toctree-wrapper compound">
<ul>
<li class="toctree-l1"><a class="reference internal" href="settings.html">Settings</a></li>
<li class="toctree-l1"><a class="reference internal" href="settings.html">Settings</a><ul>
<li class="toctree-l2"><a class="reference internal" href="settings.html#allow-slug-change">ALLOW_SLUG_CHANGE</a></li>
<li class="toctree-l2"><a class="reference internal" href="settings.html#cache-view-length">CACHE_VIEW_LENGTH</a></li>
<li class="toctree-l2"><a class="reference internal" href="settings.html#relation-models">RELATION_MODELS</a></li>
<li class="toctree-l2"><a class="reference internal" href="settings.html#m2m-registry">M2M_REGISTRY</a></li>
<li class="toctree-l2"><a class="reference internal" href="settings.html#fk-registry">FK_REGISTRY</a></li>
<li class="toctree-l2"><a class="reference internal" href="settings.html#thumbnail-upload-path">THUMBNAIL_UPLOAD_PATH</a></li>
<li class="toctree-l2"><a class="reference internal" href="settings.html#thumbnail-storage">THUMBNAIL_STORAGE</a></li>
</ul>
</li>
</ul>
</div>
</div>

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Settings &mdash; Django Categories v0.6beta1 documentation</title>
<title>Settings &mdash; Django Categories v0.6 documentation</title>
<link rel="stylesheet" href="../_static/default.css" type="text/css" />
<link rel="stylesheet" href="../_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '../',
VERSION: '0.6beta1',
VERSION: '0.6',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,13 +21,13 @@
<script type="text/javascript" src="../_static/jquery.js"></script>
<script type="text/javascript" src="../_static/underscore.js"></script>
<script type="text/javascript" src="../_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.6beta1 documentation" href="../index.html" />
<link rel="top" title="Django Categories v0.6 documentation" href="../index.html" />
<link rel="up" title="Reference" href="index.html" />
<link rel="prev" title="Reference" href="index.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.6beta1 documentation</p>
<p>Django Categories v0.6 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Settings</h1></div>
@ -87,7 +87,55 @@
<div class="body">
<div class="section" id="settings">
<h1>Settings<a class="headerlink" href="#settings" title="Permalink to this headline"></a></h1>
<span id="reference-settings"></span><h1>Settings<a class="headerlink" href="#settings" title="Permalink to this headline"></a></h1>
<p>The <tt class="docutils literal"><span class="pre">CATEGORIES_SETTINGS</span></tt> dictionary is where you can override the default settings. You don&#8217;t have to include all the settings; only the ones which you want to override.</p>
<p>The default settings are:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">CATEGORIES_SETTINGS</span> <span class="o">=</span> <span class="p">{</span>
<span class="s">&#39;ALLOW_SLUG_CHANGE&#39;</span><span class="p">:</span> <span class="bp">False</span><span class="p">,</span>
<span class="s">&#39;CACHE_VIEW_LENGTH&#39;</span><span class="p">:</span> <span class="mi">0</span><span class="p">,</span>
<span class="s">&#39;RELATION_MODELS&#39;</span><span class="p">:</span> <span class="p">[],</span>
<span class="s">&#39;M2M_REGISTRY&#39;</span><span class="p">:</span> <span class="p">[],</span>
<span class="s">&#39;FK_REGISTRY&#39;</span><span class="p">:</span> <span class="p">[],</span>
<span class="s">&#39;THUMBNAIL_UPLOAD_PATH&#39;</span><span class="p">:</span> <span class="s">&#39;uploads/categories/thumbnails&#39;</span><span class="p">,</span>
<span class="s">&#39;THUMBNAIL_STORAGE&#39;</span><span class="p">:</span> <span class="n">settings</span><span class="o">.</span><span class="n">DEFAULT_FILE_STORAGE</span><span class="p">,</span>
<span class="p">}</span>
</pre></div>
</div>
<div class="section" id="allow-slug-change">
<h2>ALLOW_SLUG_CHANGE<a class="headerlink" href="#allow-slug-change" title="Permalink to this headline"></a></h2>
<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="cache-view-length">
<h2>CACHE_VIEW_LENGTH<a class="headerlink" href="#cache-view-length" title="Permalink to this headline"></a></h2>
<p><strong>Default:</strong> <tt class="docutils literal"><span class="pre">0</span></tt></p>
<p><strong>Description:</strong> This setting will be deprecated soon, but in the mean time, it allows you to specify the amount of time each view result is cached.</p>
</div>
<div class="section" id="relation-models">
<h2>RELATION_MODELS<a class="headerlink" href="#relation-models" title="Permalink to this headline"></a></h2>
<p><strong>Default:</strong> <tt class="docutils literal"><span class="pre">[]</span></tt></p>
<p><strong>Description:</strong> Relation models is a set of models that a user can associate with this category. You specify models using <tt class="docutils literal"><span class="pre">'app_name.modelname'</span></tt> syntax.</p>
</div>
<div class="section" id="m2m-registry">
<h2>M2M_REGISTRY<a class="headerlink" href="#m2m-registry" title="Permalink to this headline"></a></h2>
<p><strong>Default:</strong> {}</p>
<p><strong>Description:</strong> A dictionary where the keys are in <tt class="docutils literal"><span class="pre">'app_name.model_name'</span></tt> syntax, and the values are a string, dict, or tuple of dicts. See <a class="reference internal" href="../registering_models.html#registering-models"><em>Registering Models</em></a>.</p>
</div>
<div class="section" id="fk-registry">
<h2>FK_REGISTRY<a class="headerlink" href="#fk-registry" title="Permalink to this headline"></a></h2>
<p><strong>Default:</strong> {}</p>
<p><strong>Description:</strong> A dictionary where the keys are in <tt class="docutils literal"><span class="pre">'app_name.model_name'</span></tt> syntax, and the values are a string, dict, or tuple of dicts. See <a class="reference internal" href="../registering_models.html#registering-models"><em>Registering Models</em></a>.</p>
</div>
<div class="section" id="thumbnail-upload-path">
<h2>THUMBNAIL_UPLOAD_PATH<a class="headerlink" href="#thumbnail-upload-path" title="Permalink to this headline"></a></h2>
<p><strong>Default:</strong> <tt class="docutils literal"><span class="pre">'uploads/categories/thumbnails'</span></tt></p>
<p><strong>Description:</strong> Where thumbnails for the categories will be saved.</p>
</div>
<div class="section" id="thumbnail-storage">
<h2>THUMBNAIL_STORAGE<a class="headerlink" href="#thumbnail-storage" title="Permalink to this headline"></a></h2>
<p><strong>Default:</strong> <tt class="docutils literal"><span class="pre">settings.DEFAULT_FILE_STORAGE</span></tt></p>
<p><strong>Description:</strong> How to store the thumbnails. Allows for external storage engines like S3.</p>
</div>
</div>

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Registering Models &mdash; Django Categories v0.6beta1 documentation</title>
<title>Registering Models &mdash; Django Categories v0.6 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.6beta1',
VERSION: '0.6',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,13 +21,13 @@
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.6beta1 documentation" href="index.html" />
<link rel="top" title="Django Categories v0.6 documentation" href="index.html" />
<link rel="next" title="Template Tags" href="templatetags.html" />
<link rel="prev" title="Using categories in templates" href="usage.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.6beta1 documentation</p>
<p>Django Categories v0.6 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Registering Models</h1></div>
@ -90,7 +90,7 @@
<div class="body">
<div class="section" id="registering-models">
<h1>Registering Models<a class="headerlink" href="#registering-models" title="Permalink to this headline"></a></h1>
<span id="id1"></span><h1>Registering Models<a class="headerlink" href="#registering-models" title="Permalink to this headline"></a></h1>
<div class="section" id="registering-models-in-settings-py">
<h2>Registering models in settings.py<a class="headerlink" href="#registering-models-in-settings-py" title="Permalink to this headline"></a></h2>
<p>It is nice to not have to modify the code of applications to add a relation to categories. You can therefore do all the registering in <tt class="docutils literal"><span class="pre">settings.py</span></tt>. For example:</p>
@ -102,7 +102,7 @@
<span class="p">{</span><span class="s">&#39;name&#39;</span><span class="p">:</span> <span class="s">&#39;secondary_category&#39;</span><span class="p">,</span> <span class="s">&#39;related_name&#39;</span><span class="p">:</span> <span class="s">&#39;mymodel_sec_cat&#39;</span><span class="p">},</span> <span class="p">)</span>
<span class="p">},</span>
<span class="s">&#39;M2M_REGISTRY&#39;</span><span class="p">:</span> <span class="p">{</span>
<span class="s">&#39;app.AModel&#39;</span><span class="p">:</span> <span class="s">&#39;categories&#39;</span><span class="p">,</span>
<span class="s">&#39;app.BModel&#39;</span><span class="p">:</span> <span class="s">&#39;categories&#39;</span><span class="p">,</span>
<span class="s">&#39;app.MyModel&#39;</span><span class="p">:</span> <span class="p">(</span><span class="s">&#39;other_categories&#39;</span><span class="p">,</span> <span class="s">&#39;more_categories&#39;</span><span class="p">,</span> <span class="p">),</span>
<span class="p">}</span>
<span class="p">}</span>
@ -110,8 +110,8 @@
</div>
<p>The <tt class="docutils literal"><span class="pre">FK_REGISTRY</span></tt> is a dictionary whose keys are the model to which to add the new field(s). The value is a string or tuple of strings or dictionaries specifying the necessary information for each field.</p>
<p>The <tt class="docutils literal"><span class="pre">M2M_REGISTRY</span></tt> is a dictionary whose keys are the model to which to add the new field(s). The value is a string or tuple of strings specifying the necessary information for each field.</p>
<div class="section" id="registering-one-category-field">
<h3>Registering One Category Field<a class="headerlink" href="#registering-one-category-field" title="Permalink to this headline"></a></h3>
<div class="section" id="registering-one-category-field-to-model">
<h3>Registering one Category field to model<a class="headerlink" href="#registering-one-category-field-to-model" title="Permalink to this headline"></a></h3>
<p>The simplest way is to specify the name of the field, such as:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">CATEGORIES_SETTINGS</span> <span class="o">=</span> <span class="p">{</span>
<span class="s">&#39;FK_REGISTRY&#39;</span><span class="p">:</span> <span class="p">{</span>
@ -124,7 +124,7 @@
<div class="highlight-python"><div class="highlight"><pre><span class="n">category</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">ForeignKey</span><span class="p">(</span><span class="n">Category</span><span class="p">)</span>
</pre></div>
</div>
<p>If you want more control over the new field, you can use a dictionary and pass other <tt class="docutils literal"><span class="pre">ForeignKey</span></tt> options:</p>
<p>If you want more control over the new field, you can use a dictionary and pass other <tt class="docutils literal"><span class="pre">ForeignKey</span></tt> options. The <tt class="docutils literal"><span class="pre">name</span></tt> key is required:</p>
<div class="highlight-python"><div class="highlight"><pre><span class="n">CATEGORIES_SETTINGS</span> <span class="o">=</span> <span class="p">{</span>
<span class="s">&#39;FK_REGISTRY&#39;</span><span class="p">:</span> <span class="p">{</span>
<span class="s">&#39;app.AModel&#39;</span><span class="p">:</span> <span class="p">{</span><span class="s">&#39;name&#39;</span><span class="p">:</span> <span class="s">&#39;category&#39;</span><span class="p">,</span> <span class="s">&#39;related_name&#39;</span><span class="p">:</span> <span class="s">&#39;amodel_cats&#39;</span><span class="p">}</span>
@ -137,6 +137,31 @@
</pre></div>
</div>
</div>
<div class="section" id="registering-two-or-more-category-fields-to-a-model">
<h3>Registering two or more Category fields to a Model<a class="headerlink" href="#registering-two-or-more-category-fields-to-a-model" title="Permalink to this headline"></a></h3>
<p>When you want more than one relation to <tt class="docutils literal"><span class="pre">Category</span></tt>, all but one of the fields must specify a <tt class="docutils literal"><span class="pre">related_name</span></tt> to avoid conflicts, like so:</p>
<div class="highlight-python"><pre>CATEGORIES_SETTINGS = {
'FK_REGISTRY': {
'app.MyModel': (
'primary_category',
{'name': 'secondary_category', 'related_name': 'mymodel_sec_cat'}, )
},</pre>
</div>
</div>
<div class="section" id="registering-one-or-more-many-to-many-category-fields-to-a-model">
<h3>Registering one or more Many-to-Many Category fields to a Model<a class="headerlink" href="#registering-one-or-more-many-to-many-category-fields-to-a-model" title="Permalink to this headline"></a></h3>
<div class="highlight-python"><div class="highlight"><pre><span class="n">CATEGORIES_SETTINGS</span> <span class="o">=</span> <span class="p">{</span>
<span class="s">&#39;M2M_REGISTRY&#39;</span><span class="p">:</span> <span class="p">{</span>
<span class="s">&#39;app.AModel&#39;</span><span class="p">:</span> <span class="s">&#39;categories&#39;</span><span class="p">,</span>
<span class="s">&#39;app.MyModel&#39;</span><span class="p">:</span> <span class="p">(</span>
<span class="p">{</span><span class="s">&#39;name&#39;</span><span class="p">:</span> <span class="s">&#39;other_categories&#39;</span><span class="p">,</span> <span class="s">&#39;related_name&#39;</span><span class="p">:</span> <span class="s">&#39;other_cats&#39;</span><span class="p">},</span>
<span class="p">{</span><span class="s">&#39;name&#39;</span><span class="p">:</span> <span class="s">&#39;more_categories&#39;</span><span class="p">,</span> <span class="s">&#39;related_name&#39;</span><span class="p">:</span> <span class="s">&#39;more_cats&#39;</span><span class="p">},</span>
<span class="p">),</span>
<span class="p">}</span>
<span class="p">}</span>
</pre></div>
</div>
</div>
</div>
<div class="section" id="registering-a-many-to-one-relationship">
<h2>Registering a many-to-one relationship<a class="headerlink" href="#registering-a-many-to-one-relationship" title="Permalink to this headline"></a></h2>

View file

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

View file

@ -1 +1 @@
Search.setIndex({objects:{"":{register_fk:[2,0,1],register_m2m:[2,0,1]}},terms:{represent:5,all:[2,3],code:2,sci:5,over:[5,2],becaus:6,syntax:3,comma:5,follow:[5,2],secondary_categori:2,children:3,paramet:2,hierarch:[],categori:[5,0,2,3,6],other_categori:2,should:5,add:[5,2,6],valid:5,dict:5,under:5,therefor:2,app:2,tree_info:5,futur:5,child1:3,child2:3,child3:3,"return":3,greater:5,amodel:2,get:[0,6],fals:5,extra_arg:2,between:2,mechan:[],mymodel_sec_set:[],"new":[5,2],field_nam:2,string:[2,3],ancestor:[5,3],name:[5,2,6],doesn:2,level:5,list:[5,3],iter:[5,3],amodel_cat:2,separ:[5,3],item:5,necessari:2,each:2,unicod:5,refer:[0,4],page:0,set:[0,1,2,3,4],some:2,sampl:5,connect:[0,6],pass:2,happen:6,even:6,index:0,what:6,appear:5,content:[5,0],version:0,simplest:2,"import":[5,2,6],method:6,attribut:6,grandpar:3,kei:[5,2],whose:2,gener:5,contain:5,category_obj:3,fk_registri:2,dictionari:2,"super":[],valu:2,addit:6,both:6,about:5,categories_set:2,last:5,would:[5,6],current:5,display_drilldown_as_ul:[0,3],foreign:2,filter:[5,0],related_nam:2,new_level:5,mani:[0,2,6],display_path_as_ul:[0,3],other:2,first:5,simpli:6,render:3,extra:[5,2],appli:[],modul:0,mymodel_sec_cat:2,href:3,subcategori:6,famili:3,clash:2,respect:6,storag:6,your:[0,2,6],given:5,wai:[2,6],few:6,modifi:2,top:[3,6],regist:[0,2],two:[5,6],empti:5,next:5,avail:5,start:[5,0,6],time:6,immedi:[5,3],more:2,"function":2,field:2,option:[5,2,3],relationship:[0,2,6],tupl:[5,2],relat:2,search:0,specifi:[5,2,3],primary_categori:2,link:2,indic:0,child:3,closed_level:5,"true":5,than:[5,2],retriev:3,provid:5,tree:[5,6],structur:5,alter:3,below:5,can:[5,2,3,6],foreignkei:[2,6],otherwis:5,root:5,document:0,control:2,featur:5,want:2,creat:[2,6],applic:2,get_top_level_categori:[0,3],argument:[5,2,3],templat:[5,0,3],manytomanyfield:2,tag:[5,0,3],right:5,have:[2,6],tabl:0,need:6,sever:6,around:5,parent:[5,3],end:5,welcom:[],equival:2,titl:[],more_categori:2,register_fk:[2,6],detail:5,same:[5,6],"default":2,html:3,descend:5,which:[5,2],m2m_registri:2,you:[2,3,6],eventu:6,nice:2,node:5,allow:2,book:5,though:6,after:5,category_tag:5,breadcrumb:[0,3],extra_param:2,data:[],"class":2,ul_tre:3,dystopian:5,get_category_drilldown:[0,3],mymodel:[2,6],django:[0,2,6],inform:[5,2],exampl:[5,2,3,6],thi:[5,2],alphabet:3,model:[0,2,6],register_m2m:[2,6],order:5},objtypes:{"0":"py:function"},titles:["Django Categories v|version| documentation!","Settings","Registering Models","Template Tags","Reference","Using categories in templates","Getting Started"],objnames:{"0":"Python function"},filenames:["index","reference/settings","registering_models","templatetags","reference/index","usage","getting_started"]})
Search.setIndex({objects:{"":{register_fk:[2,0,1],register_m2m:[2,0,1]}},terms:{represent:5,all:[1,2,3],code:2,sci:5,control:2,over:[5,2],becaus:6,syntax:[1,3],comma:5,follow:[5,2],secondary_categori:2,data:[],children:3,paramet:2,hierarch:[],categori:[0,1,2,3,5,6],onli:1,"default":[1,2],other_categori:2,should:5,add:[5,2,6],valid:5,dict:[5,1],under:5,therefor:2,app:2,tree_info:5,futur:5,child1:3,child2:3,child3:3,"return":3,string:[1,2,3],amodel:2,bmodel:2,fals:[5,1],extra_arg:2,simplest:2,soon:1,mechan:[],mymodel_sec_set:[],"new":[5,2],field_nam:2,model_nam:1,mymodel_sec_cat:2,requir:2,like:[1,2],eventu:6,name:[5,2],doesn:2,level:5,other_cat:2,list:[5,3],upload:1,iter:[5,3],amodel_cat:2,separ:[5,3],item:5,necessari:2,contain:5,unicod:5,refer:[0,4],where:1,page:0,view:1,set:[0,1,2,3,4,6],some:2,consequ:1,see:[1,6],sampl:5,connect:[0,6],pass:2,parent:[5,3],happen:6,time:[1,6],even:6,index:0,what:6,appear:5,avoid:2,content:[5,0],method:6,version:0,cache_view_length:[4,1],between:2,"import":[5,2],thumbnail:1,attribut:6,grandpar:3,kei:[5,1,2],whose:2,gener:5,each:[1,2],category_obj:3,allow_slug_chang:[4,1],fk_registri:[4,1,2,6],dictionari:[1,2],"super":[],slug:1,valu:[1,2],addit:6,both:6,about:5,categories_set:[1,2,6],last:5,would:5,current:5,display_drilldown_as_ul:[0,3],greater:5,foreign:2,filter:[5,0],amount:1,related_nam:2,new_level:5,mani:[0,2,6],chang:1,mean:1,other:2,first:5,thumbnail_storag:[4,1],simpli:6,render:3,extra:[5,2],appli:[],modul:0,deprec:1,href:3,subcategori:6,famili:3,clash:2,respect:6,storag:[1,6],your:[0,2,6],given:5,wai:[2,6],few:6,associ:1,top:[3,6],regist:[0,1,2,6],two:[5,2,6],empti:5,next:5,avail:5,start:[5,0,6],includ:1,which:[5,1,2],immedi:[5,3],store:1,more:[2,6],"function":2,field:2,option:[5,2,3],relationship:[0,2,6],tupl:[5,1,2],relat:[1,2],search:0,specifi:[5,1,2,3],primary_categori:2,part:1,modifi:2,indic:0,child:3,closed_level:5,"true":[5,1],than:[5,2],must:2,save:1,retriev:3,provid:5,when:2,tree:[5,6],modelnam:1,structur:5,alter:3,below:5,can:[5,1,2,3,6],cach:1,foreignkei:[2,6],otherwis:5,root:5,app_nam:1,overrid:1,featur:5,want:[1,2],creat:[2,6],applic:2,get_top_level_categori:[0,3],argument:[5,2,3],templat:[5,0,3],manytomanyfield:2,tag:[5,0,3],right:5,have:[1,2,3],tabl:0,need:6,thumbnail_upload_path:[4,1],sever:6,around:5,result:1,more_categori:2,end:5,welcom:[],equival:2,alphabet:3,ancestor:[5,3],get:[0,6],register_fk:2,detail:5,same:[5,6],ul_tre:3,how:1,more_cat:2,html:3,descend:5,default_file_storag:1,m2m_registri:[4,1,2,6],you:[1,2,3,6],document:0,conflict:2,nice:2,node:5,allow:[1,2],book:5,though:6,after:5,category_tag:5,breadcrumb:[0,3],extra_param:2,user:1,extern:1,engin:1,relation_model:[4,1],"class":2,display_path_as_ul:[0,3],don:1,dystopian:5,get_category_drilldown:[0,3],url:1,seriou:1,mymodel:2,descript:1,django:[0,2,6],inform:[5,2,6],exampl:[5,2,3],thi:[5,1,2],titl:[],link:2,model:[0,1,2,6],register_m2m:2,order:5},objtypes:{"0":"py:function"},titles:["Django Categories v|version| documentation!","Settings","Registering Models","Template Tags","Reference","Using categories in templates","Getting Started"],objnames:{"0":"Python function"},filenames:["index","reference/settings","registering_models","templatetags","reference/index","usage","getting_started"]})

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Template Tags &mdash; Django Categories v0.6beta1 documentation</title>
<title>Template Tags &mdash; Django Categories v0.6 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.6beta1',
VERSION: '0.6',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,12 +21,13 @@
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.6beta1 documentation" href="index.html" />
<link rel="top" title="Django Categories v0.6 documentation" href="index.html" />
<link rel="next" title="Reference" href="reference/index.html" />
<link rel="prev" title="Registering Models" href="registering_models.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.6beta1 documentation</p>
<p>Django Categories v0.6 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Template Tags</h1></div>
@ -34,6 +35,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="reference/index.html" title="Reference" accesskey="N">next</a></div>
<div class="headerButton"><a href="registering_models.html" title="Registering Models" accesskey="P">previous</a></div>
</li>
</ul>
@ -54,6 +56,7 @@
<li class="toctree-l2"><a class="reference internal" href="#breadcrumbs-tag">breadcrumbs tag</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="reference/index.html">Reference</a></li>
</ul>
<h3>This Page</h3>
@ -92,7 +95,7 @@
<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.</p>
<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>
</pre></div>
@ -139,7 +142,7 @@ as an iterable.</p>
</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, but no children using the
<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>
<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>

View file

@ -6,13 +6,13 @@
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Using categories in templates &mdash; Django Categories v0.6beta1 documentation</title>
<title>Using categories in templates &mdash; Django Categories v0.6 documentation</title>
<link rel="stylesheet" href="_static/default.css" type="text/css" />
<link rel="stylesheet" href="_static/pygments.css" type="text/css" />
<script type="text/javascript">
var DOCUMENTATION_OPTIONS = {
URL_ROOT: '',
VERSION: '0.6beta1',
VERSION: '0.6',
COLLAPSE_INDEX: false,
FILE_SUFFIX: '.html',
HAS_SOURCE: true
@ -21,13 +21,13 @@
<script type="text/javascript" src="_static/jquery.js"></script>
<script type="text/javascript" src="_static/underscore.js"></script>
<script type="text/javascript" src="_static/doctools.js"></script>
<link rel="top" title="Django Categories v0.6beta1 documentation" href="index.html" />
<link rel="top" title="Django Categories v0.6 documentation" href="index.html" />
<link rel="next" title="Registering Models" href="registering_models.html" />
<link rel="prev" title="Getting Started" href="getting_started.html" />
</head>
<body>
<div id="docstitle">
<p>Django Categories v0.6beta1 documentation</p>
<p>Django Categories v0.6 documentation</p>
</div>
<div id="header">
<div id="title"><h1>Using categories in templates</h1></div>
@ -52,6 +52,7 @@
</li>
<li class="toctree-l1"><a class="reference internal" href="registering_models.html">Registering Models</a></li>
<li class="toctree-l1"><a class="reference internal" href="templatetags.html">Template Tags</a></li>
<li class="toctree-l1"><a class="reference internal" href="reference/index.html">Reference</a></li>
</ul>
<h3>This Page</h3>