Models#
CategoryBase#
- class CategoryBase#
- parent#
TreeForeignKey(self)The category’s parent category. Leave this blank for an root category.
- name#
Required
CharField(100)The name of the category.
- slug#
Required
SlugFieldURL-friendly title. It is automatically generated from the title.
- active#
Required
BooleanFielddefault:TrueIs this item active. If it is inactive, all children are set to inactive as well.
- objects#
CategoryManagerAn object manager that adds an
activemethod for only selecting items whoseactiveattribute isTrue.
- tree#
TreeManagerA Django-MPTT TreeManager instance.
Category#
- class Category#
Category is a subclass of
CategoryBaseand includes all its attributes.- thumbnail#
FileFieldAn optional thumbnail, that is uploaded to REGISTER_ADMIN via THUMBNAIL_STORAGE.
Note
Why isn’t this an
ImageField?For
ImageFields, Django checks the file system for the existance of the files to handle the height and width. In many cases this can lead to problems and impact performance.For these reasons, a
FileFieldthat manually manages the width and height was chosen.
- thumbnail_width#
IntegerFieldThe thumbnail width. Automatically set on save if a thumbnail is uploaded.
- thumbnail_height#
IntegerFieldThe thumbnail height. Automatically set on save if a thumbnail is uploaded.
- order#
Required
IntegerFielddefault: 0A manually-managed order of this category in the listing. Items with the same order are sorted alphabetically.
- alternate_title#
CharField(100)An alternative title to use on pages with this category.
- alternate_url#
CharField(200)An alternative URL to use instead of the one derived from the category hierarchy.
Note
Why isn’t this a
URLField?For
URLFields, Django checks that the URL includeshttp://and the site name. This makes it impossible to use relative URLs in that field.
- description#
TextFieldAn optional longer description of the category. Very useful on category landing pages.
- meta_keywords#
CharField(255)Comma-separated keywords for search engines.
- meta_extra#
TextField(Advanced) Any additional HTML to be placed verbatim in the
<head>of the page.