Permalink
Browse files

Updating the documentation.

  • Loading branch information...
1 parent d48be41 commit ed4db03c7ddeb20fde5f7951ea9895f2aadca42f Corey Oordt committed Aug 1, 2011
View
@@ -1,8 +1,6 @@
-===========================================
-Django Categories v|version| documentation!
-===========================================
-
-
+=============================
+Django Categories v |version|
+=============================
Contents:
@@ -13,7 +11,7 @@ Contents:
getting_started
usage
registering_models
- templatetags
+ adding_the_fields
reference/index
Indices and tables
@@ -9,3 +9,4 @@ Reference
management_commands
models
settings
+ templatetags
@@ -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.
View
@@ -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:
@@ -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``
@@ -54,11 +54,16 @@ Hard coded connections are done in the exact same way you handle any other forei
name = models.CharField(max_length=100)
category = models.ForeignKey('categories.Category')
+Don't forget to add the field or fields to your ``ModelAdmin`` class as well.
+
.. _lazy_connection:
Lazy Connection
***************
+Lazy connections are done through configuring Django Categories in the project's ``settings.py`` file. When the project starts up, the configured fields are dynamically added to the configured models and admin.
+
+If you do this before you have created the database (before you ran ``manage.py syncdb``), the fields will also be in the tables. If you do this after you have already created all the tables, you can run ``manage.py add_category_fields`` to create the fields (this requires Django South to be installed).
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`\ .
@@ -1,8 +1,6 @@
-===========================================
-Django Categories v|version| documentation!
-===========================================
-
-
+=============================
+Django Categories v |version|
+=============================
Contents:
@@ -13,7 +11,7 @@ Contents:
getting_started
usage
registering_models
- templatetags
+ adding_the_fields
reference/index
Indices and tables
@@ -6,4 +6,7 @@ Reference
:maxdepth: 2
:glob:
- settings
+ management_commands
+ models
+ settings
+ templatetags
@@ -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.
@@ -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>``
@@ -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
@@ -95,6 +95,8 @@ Registering one or more Many-to-Many Category fields to a Model
}
}
+.. _registering_a_m2one_relationship:
+
Registering a many-to-one relationship
======================================
Oops, something went wrong.

0 comments on commit ed4db03

Please sign in to comment.