diff --git a/doc_src/index.rst b/doc_src/index.rst index 75142c0..d78f824 100644 --- a/doc_src/index.rst +++ b/doc_src/index.rst @@ -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 diff --git a/doc_src/reference/index.rst b/doc_src/reference/index.rst index 15afed2..9bca020 100644 --- a/doc_src/reference/index.rst +++ b/doc_src/reference/index.rst @@ -9,3 +9,4 @@ Reference management_commands models settings + templatetags diff --git a/doc_src/reference/models.rst b/doc_src/reference/models.rst new file mode 100644 index 0000000..2f66ba8 --- /dev/null +++ b/doc_src/reference/models.rst @@ -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 ``
`` diff --git a/doc_src/templatetags.rst b/doc_src/reference/templatetags.rst similarity index 100% rename from doc_src/templatetags.rst rename to doc_src/reference/templatetags.rst diff --git a/docs/.buildinfo b/docs/.buildinfo index 336f91a..0885fbe 100644 --- a/docs/.buildinfo +++ b/docs/.buildinfo @@ -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: diff --git a/docs/_sources/adding_the_fields.txt b/docs/_sources/adding_the_fields.txt new file mode 100644 index 0000000..a6a920f --- /dev/null +++ b/docs/_sources/adding_the_fields.txt @@ -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 +*********** + +`SouthDjango Categories v0.7beta1 documentation
+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.
+South 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.
+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 Registering a many-to-one 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
+Django Categories v0.6 documentation
+Django Categories v0.7beta1 documentation
Django Categories v0.6 documentation
+Django Categories v0.7beta1 documentation
You can’t do it as both at the same time, though.
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.
+There are two ways to add Category fields to an application. If you are in control of the code (it’s your application) or you are willing to take control of the code (fork someone else’s app) you can make a Hard Coded Connection.
+For 3rd-party apps or even your own apps that you don’t wish to add Django-Categories as a dependency, you can configure a Lazy Connection.
+Hard coded connections are done in the exact same way you handle any other foreign key or many-to-many relations to a model.
+from django.db import models
+
+class MyModel(models.Model):
+ 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 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 Registering Models.
Django Categories v0.6 documentation
+Django Categories v0.7beta1 documentation
Contents:
Django Categories v0.6 documentation
+Django Categories v0.7beta1 documentation
Django Categories v0.7beta1 documentation
+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.
+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.
+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.
+Django Categories v0.7beta1 documentation
+Django Categories v0.6 documentation
+Django Categories v0.7beta1 documentation
Django Categories v0.7beta1 documentation
+Retrieves an alphabetical list of all the categories that have no parents.
+Syntax:
+{% get_top_level_categories as categories %}
+Returns an list of categories [<category>, <category>, <category, ...]
+Render the category with ancestors, but no children using the categories/ul_tree.html template.
+Example:
+{% display_path_as_ul "/Grandparent/Parent" %}
+or
+{% display_path_as_ul category_obj %}
+Returns:
+<ul>
+ <li><a href="/categories/">Top</a>
+ <ul>
+ <li><a href="/categories/grandparent/">Grandparent</a></li>
+ </ul>
+ </li>
+</ul>
+Retrieves the specified category, its ancestors and its immediate children +as an iterable.
+Example:
+{% get_category_drilldown "/Grandparent/Parent" as family %}
+or
+{% get_category_drilldown category_obj as family %}
+Sets family to:
+[Grandparent, Parent, Child 1, Child 2, Child n]
+Render the category with ancestors and children using the +categories/ul_tree.html template.
+Example:
+{% display_drilldown_as_ul "/Grandparent/Parent" %}
+or:
+{% display_drilldown_as_ul category_obj %}
+Returns:
+<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>
+Render breadcrumbs, using the categories/breadcrumbs.html template, using the optional separator argument.
+Example:
+{% breadcrumbs "/Grandparent/Parent" %}
+or:
+{% breadcrumbs category_obj %}
+Returns:
+<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:
+{% breadcrumbs category_obj "::" %}
+Returns:
+<a href="/categories/grandparent/">Grandparent</a> :: Parent
+Django Categories v0.6 documentation
+Django Categories v0.7beta1 documentation
To create a many-to-one relationship (foreign key) between a model and Django Categories, you register your model with the register_fk function.
Django Categories v0.6 documentation
+Django Categories v0.7beta1 documentation
Django Categories v0.6 documentation
+Django Categories v0.7beta1 documentation
Django Categories v0.6 documentation
+Django Categories v0.7beta1 documentation