-
-
Notifications
You must be signed in to change notification settings - Fork 135
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Corey Oordt
committed
Aug 1, 2011
1 parent
d48be41
commit ed4db03
Showing
28 changed files
with
1,056 additions
and
87 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,3 +9,4 @@ Reference | |
management_commands | ||
models | ||
settings | ||
templatetags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
====== | ||
Models | ||
====== | ||
|
||
Category | ||
======== | ||
|
||
**parent** | ||
The category's parent category. Leave this blank for an Category Tree. | ||
|
||
**name** | ||
The name of the category. | ||
|
||
**thumbnail** | ||
An optional thumbnail, that is uploaded to ``CATEGORY_SETTINGS['THUMBNAIL_UPLOAD_PATH']`` via ``CATEGORY_SETTINGS['THUMBNAIL_STORAGE']``\ . | ||
|
||
**thumbnail_width** | ||
The thumbnail width. | ||
|
||
**thumbnail_height** | ||
The thumbnail height. | ||
|
||
**order** | ||
The order of this category in the listing | ||
|
||
**slug** | ||
A slug created from the name field | ||
|
||
**alternate_title** | ||
An alternative title to use on pages with this category. | ||
|
||
**alternate_url** | ||
An alternative URL to use instead of the one derived from the category hierarchy. | ||
|
||
**description** | ||
An optional longer description of the category. | ||
|
||
**meta_keywords** | ||
Comma-separated keywords for search engines. | ||
|
||
**meta_extra** | ||
(Advanced) Any additional HTML to be placed verbatim in the ``<head>`` |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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: 0f579989dd4cbe4af0af63fb63e64641 | ||
tags: fbb0d17656682115ca4d033fb2f83ba1 | ||
config: | ||
tags: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
.. _adding_the_fields: | ||
|
||
================================= | ||
Adding the fields to the database | ||
================================= | ||
|
||
While Django will create the appropriate columns and tables if you configure Django Categories first, many times that is not possible. You could also reset the table, but you would loose all data in it. There is another way. | ||
|
||
Enter South | ||
*********** | ||
|
||
`South <http://south.aeracode.org/>`_ is a Django application for managing database schema changes. South's default behavior is for managing permanent changes to a model's structure. In the case of dynamically adding a field or fields to a model, this doesn't work because you are not making the change permanent. And probably don't want to. | ||
|
||
Django Categories has a management command to create any missing fields. It requires South because it uses the South's API for making changes to databases. The management command is simple: ``python manage.py add_category_fields [app]``\ . If you do not include an app name, it will attempt to do all applications configured. | ||
|
||
Running this command several times will not hurt any data or cause any errors. | ||
|
||
Reconfiguring Fields | ||
******************** | ||
|
||
You can make changes to the field configurations as long as they do not change the underlying database structure. For example, adding a ``related_name`` (see :ref:`registering_a_m2one_relationship`\ ) because it only affects Django code. Changing the name of the field, however, is a different matter. | ||
|
||
Django Categories provides a complementary management command to drop a field from the database (the field must still be in the configuration to do so): ``python manage.py drop_category_field app_name model_name field_name`` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,4 +6,7 @@ Reference | |
:maxdepth: 2 | ||
:glob: | ||
|
||
settings | ||
management_commands | ||
models | ||
settings | ||
templatetags |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
.. _management-commands: | ||
|
||
=================== | ||
Management Commands | ||
=================== | ||
|
||
.. _import_categories: | ||
|
||
import_categories | ||
================= | ||
|
||
**Usage:** ``./manage.py import_categories /path/to/file.txt [/path/to/file2.txt]`` | ||
|
||
Imports category tree(s) from a file. Sub categories must be indented by the same multiple of spaces or tabs. The first line in the file cannot start with a space or tab and you can't mix spaces and tabs. | ||
|
||
|
||
.. _add_category_fields: | ||
|
||
add_category_fields | ||
=================== | ||
|
||
**Usage:** ``./manage.py add_category_fields [app1 app2 ...]`` | ||
|
||
Add missing registered category fields to the database table of a specified application or all registered applications. | ||
|
||
Requires Django South. | ||
|
||
|
||
.. _drop_category_fields: | ||
|
||
drop_category_fields | ||
=================== | ||
|
||
**Usage:** ``./manage.py drop_category_field app_name model_name field_name`` | ||
|
||
Drop the ``field_name`` field from the ``app_name_model_name`` table, if the field is currently registered in ``CATEGORIES_SETTINGS``\ . | ||
|
||
Requires Django South. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
====== | ||
Models | ||
====== | ||
|
||
Category | ||
======== | ||
|
||
**parent** | ||
The category's parent category. Leave this blank for an Category Tree. | ||
|
||
**name** | ||
The name of the category. | ||
|
||
**thumbnail** | ||
An optional thumbnail, that is uploaded to ``CATEGORY_SETTINGS['THUMBNAIL_UPLOAD_PATH']`` via ``CATEGORY_SETTINGS['THUMBNAIL_STORAGE']``\ . | ||
|
||
**thumbnail_width** | ||
The thumbnail width. | ||
|
||
**thumbnail_height** | ||
The thumbnail height. | ||
|
||
**order** | ||
The order of this category in the listing | ||
|
||
**slug** | ||
A slug created from the name field | ||
|
||
**alternate_title** | ||
An alternative title to use on pages with this category. | ||
|
||
**alternate_url** | ||
An alternative URL to use instead of the one derived from the category hierarchy. | ||
|
||
**description** | ||
An optional longer description of the category. | ||
|
||
**meta_keywords** | ||
Comma-separated keywords for search engines. | ||
|
||
**meta_extra** | ||
(Advanced) Any additional HTML to be placed verbatim in the ``<head>`` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,146 @@ | ||
============= | ||
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 as categories %} | ||
|
||
Returns an list of categories ``[<category>, <category>, <category, ...]`` | ||
|
||
|
||
display_path_as_ul | ||
================== | ||
|
||
Render the category with ancestors, but no children using the ``categories/ul_tree.html`` template. | ||
|
||
Example: | ||
|
||
.. code-block:: django | ||
|
||
{% display_path_as_ul "/Grandparent/Parent" %} | ||
|
||
or | ||
|
||
.. code-block:: django | ||
|
||
{% display_path_as_ul category_obj %} | ||
|
||
Returns: | ||
|
||
.. code-block:: html | ||
|
||
<ul> | ||
<li><a href="/categories/">Top</a> | ||
<ul> | ||
<li><a href="/categories/grandparent/">Grandparent</a></li> | ||
</ul> | ||
</li> | ||
</ul> | ||
|
||
|
||
get_category_drilldown | ||
====================== | ||
|
||
Retrieves the specified category, its ancestors and its immediate children | ||
as an iterable. | ||
|
||
Example: | ||
|
||
.. code-block:: django | ||
|
||
{% get_category_drilldown "/Grandparent/Parent" as family %} | ||
|
||
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: | ||
|
||
.. code-block:: django | ||
|
||
{% display_drilldown_as_ul "/Grandparent/Parent" %} | ||
|
||
or: | ||
|
||
.. code-block:: django | ||
|
||
{% display_drilldown_as_ul category_obj %} | ||
|
||
Returns: | ||
|
||
.. code-block:: html | ||
|
||
<ul> | ||
<li><a href="/categories/">Top</a> | ||
<ul> | ||
<li><a href="/categories/grandparent/">Grandparent</a> | ||
<ul> | ||
<li><a href="/categories/grandparent/parent/">Parent</a> | ||
<ul> | ||
<li><a href="/categories/grandparent/parent/child1">Child1</a></li> | ||
<li><a href="/categories/grandparent/parent/child2">Child2</a></li> | ||
<li><a href="/categories/grandparent/parent/child3">Child3</a></li> | ||
</ul> | ||
</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
</li> | ||
</ul> | ||
|
||
|
||
breadcrumbs tag | ||
=============== | ||
|
||
Render breadcrumbs, using the ``categories/breadcrumbs.html`` template, using the optional ``separator`` argument. | ||
|
||
Example: | ||
|
||
.. code-block:: django | ||
|
||
{% breadcrumbs "/Grandparent/Parent" %} | ||
|
||
or: | ||
|
||
.. code-block:: django | ||
|
||
{% breadcrumbs category_obj %} | ||
|
||
Returns: | ||
|
||
.. code-block:: html | ||
|
||
<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: | ||
|
||
.. code-block:: django | ||
|
||
{% breadcrumbs category_obj "::" %} | ||
|
||
Returns: | ||
|
||
.. code-block:: html | ||
|
||
<a href="/categories/grandparent/">Grandparent</a> :: Parent |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.