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 SlugField

URL-friendly title. It is automatically generated from the title.

active#

Required BooleanField default: True

Is this item active. If it is inactive, all children are set to inactive as well.

objects#

CategoryManager

An object manager that adds an active method for only selecting items whose active attribute is True.

tree#

TreeManager

A Django-MPTT TreeManager instance.

Category#

class Category#

Category is a subclass of CategoryBase and includes all its attributes.

thumbnail#

FileField

An 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 FileField that manually manages the width and height was chosen.

thumbnail_width#

IntegerField

The thumbnail width. Automatically set on save if a thumbnail is uploaded.

thumbnail_height#

IntegerField

The thumbnail height. Automatically set on save if a thumbnail is uploaded.

order#

Required IntegerField default: 0

A 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 includes http:// and the site name. This makes it impossible to use relative URLs in that field.

description#

TextField

An 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.