From c676fc1c8dbc92afaef9760f022b7bde5e9db076 Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Sun, 4 Sep 2011 19:57:58 -0400 Subject: [PATCH] Updated docs adding usage in templates and rendered --- doc_src/usage.rst | 26 ++++++-- doc_src/usage_example_template.html | 28 +++++++++ docs/_sources/usage.txt | 26 ++++++-- docs/adding_the_fields.html | 8 +-- docs/genindex.html | 8 +-- docs/getting_started.html | 12 ++-- docs/index.html | 17 ++--- docs/objects.inv | Bin 503 -> 505 bytes docs/reference/index.html | 8 +-- docs/reference/management_commands.html | 8 +-- docs/reference/models.html | 8 +-- docs/reference/settings.html | 8 +-- docs/reference/templatetags.html | 8 +-- docs/registering_models.html | 8 +-- docs/search.html | 8 +-- docs/searchindex.js | 2 +- docs/usage.html | 80 +++++++++++++++++++++--- 17 files changed, 196 insertions(+), 67 deletions(-) create mode 100644 doc_src/usage_example_template.html diff --git a/doc_src/usage.rst b/doc_src/usage.rst index 3bcde13..c54c3b2 100644 --- a/doc_src/usage.rst +++ b/doc_src/usage.rst @@ -2,12 +2,29 @@ Using categories in templates ============================= -To use the template tags::: + +Getting all items within a category +=================================== + +The :py:class:`Category` model automatically gets `reverse relationships `_ with all other models related to it. + +This allows you access to the related objects from the template without altering any views. For example, if you only had ``Entry`` models related to :py:class:`Category`, your ``categories/category_detail.html`` template could look like + +.. literalinclude:: usage_example_template.html + :language: django + :linenos: + + +If you have ``related_name`` parameters to the configuration (see :ref:`registering_models`), then you would use ``category.related_name.all`` instead of ``category.relatedmodel_set.all``\ . + + +Template Tags +============= + +To use the template tags:: {% import category_tags %} -Filters -******* ``tree_info`` ------------- @@ -41,4 +58,5 @@ comma-separated list of feature names. The valid feature names are: Books -> [] Sci-fi -> [u'Books'] - Dystopian Futures -> [u'Books', u'Sci-fi'] \ No newline at end of file + Dystopian Futures -> [u'Books', u'Sci-fi'] + diff --git a/doc_src/usage_example_template.html b/doc_src/usage_example_template.html new file mode 100644 index 0000000..b0bee73 --- /dev/null +++ b/doc_src/usage_example_template.html @@ -0,0 +1,28 @@ +{% extends 'categories/base.html' %} +{% block content %} +

{{ category }}

+{% if category.parent %} +

Go up to + + {{ category.parent }} +

+{% endif %} +{% if category.description %}

{{ category.description }}

{% endif %} +{% if category.children.count %} +

Subcategories

+ +{% endif %} +

Entries

+{% if category.entries_set.all %} + {% for entry in category.entries_set.all %} +

{{ entry.headline }}

+ {% endfor %} +{% else %} +

No entries for {{ category }}

+{% endif %} + +{% endblock %} \ No newline at end of file diff --git a/docs/_sources/usage.txt b/docs/_sources/usage.txt index 3bcde13..c54c3b2 100644 --- a/docs/_sources/usage.txt +++ b/docs/_sources/usage.txt @@ -2,12 +2,29 @@ Using categories in templates ============================= -To use the template tags::: + +Getting all items within a category +=================================== + +The :py:class:`Category` model automatically gets `reverse relationships `_ with all other models related to it. + +This allows you access to the related objects from the template without altering any views. For example, if you only had ``Entry`` models related to :py:class:`Category`, your ``categories/category_detail.html`` template could look like + +.. literalinclude:: usage_example_template.html + :language: django + :linenos: + + +If you have ``related_name`` parameters to the configuration (see :ref:`registering_models`), then you would use ``category.related_name.all`` instead of ``category.relatedmodel_set.all``\ . + + +Template Tags +============= + +To use the template tags:: {% import category_tags %} -Filters -******* ``tree_info`` ------------- @@ -41,4 +58,5 @@ comma-separated list of feature names. The valid feature names are: Books -> [] Sci-fi -> [u'Books'] - Dystopian Futures -> [u'Books', u'Sci-fi'] \ No newline at end of file + Dystopian Futures -> [u'Books', u'Sci-fi'] + diff --git a/docs/adding_the_fields.html b/docs/adding_the_fields.html index e5f6586..b1777c6 100644 --- a/docs/adding_the_fields.html +++ b/docs/adding_the_fields.html @@ -6,13 +6,13 @@ - Adding the fields to the database — Django Categories v0.8 documentation + Adding the fields to the database — Django Categories v0.8.2 documentation - +
-

Django Categories v0.8 documentation

+

Django Categories v0.8.2 documentation