From e4f3e9384882fcacf083e4f0231450d8fb1fb313 Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Sun, 4 Sep 2011 19:56:02 -0400 Subject: [PATCH 1/3] Fix Issue #25 : The override of __getitem__ was causing issues with analysis of query sets, --- editor/tree_editor.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/editor/tree_editor.py b/editor/tree_editor.py index c5a4332..e08365d 100644 --- a/editor/tree_editor.py +++ b/editor/tree_editor.py @@ -50,8 +50,10 @@ class TreeEditorQuerySet(QuerySet): for obj in super(TreeEditorQuerySet, qs).iterator(): yield obj - def __getitem__(self, index): - return self # Don't even try to slice + # Although slicing isn't nice in a tree, it is used in the deletion action + # in the admin changelist. This causes github issue #25 + # def __getitem__(self, index): + # return self # Don't even try to slice def get(self, *args, **kwargs): """ From fdbb08431e4b3d8bc1c45ea2c5972da0d881becb Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Sun, 4 Sep 2011 19:56:22 -0400 Subject: [PATCH 2/3] Version bump to 0.8.2 --- categories/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/categories/__init__.py b/categories/__init__.py index d91ae12..842c5d8 100644 --- a/categories/__init__.py +++ b/categories/__init__.py @@ -1,7 +1,7 @@ __version_info__ = { 'major': 0, 'minor': 8, - 'micro': 1, + 'micro': 2, 'releaselevel': 'final', 'serial': 1 } From c676fc1c8dbc92afaef9760f022b7bde5e9db076 Mon Sep 17 00:00:00 2001 From: Corey Oordt Date: Sun, 4 Sep 2011 19:57:58 -0400 Subject: [PATCH 3/3] 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

+
    + {% for child in category.children.all %} +
  • {{ child }}
  • + {% endfor %} +
+{% 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