categories.models.Category
Category#
- class categories.models.Category(*args, **kwargs)[source]#
A basic category model.
- Parameters:
id (AutoField) – Primary key: ID
name (CharField) – Name
slug (SlugField) – Slug
active (BooleanField) – Active
thumbnail (FileField) – Thumbnail
thumbnail_width (IntegerField) – Thumbnail width
thumbnail_height (IntegerField) – Thumbnail height
order (IntegerField) – Order
alternate_title (CharField) – Alternate title. An alternative title to use on pages with this category.
alternate_url (CharField) – Alternate url. An alternative URL to use instead of the one derived from the category hierarchy.
description (TextField) – Description
meta_keywords (CharField) – Meta keywords. Comma-separated keywords for search engines.
meta_extra (TextField) – Meta extra. (Advanced) Any additional HTML to be placed verbatim in the <head>
lft (PositiveIntegerField) – Lft
rght (PositiveIntegerField) – Rght
tree_id (PositiveIntegerField) – Tree id
level (PositiveIntegerField) – Level
Relationship fields:
- Parameters:
parent (
TreeForeignKeytoCategory) – Parent (related name:children)
Reverse relationships:
- Parameters:
flatpage (Reverse
ForeignKeyfromFlatPage) – All flat pages of this category (related name ofcategory)other_cats (Reverse
ManyToManyFieldfromFlatPage) – All other cats of this category (related name ofother_categories)more_cats (Reverse
ManyToManyFieldfromFlatPage) – All more cats of this category (related name ofmore_categories)children (Reverse
TreeForeignKeyfromCategory) – All children of this category (related name ofparent)categoryrelation (Reverse
ForeignKeyfromCategoryRelation) – All category relations of this category (related name ofcategory)simpletext (Reverse
ForeignKeyfromSimpleText) – All Simple Text of this category (related name ofprimary_category)simpletext_sec_cat (Reverse
ForeignKeyfromSimpleText) – All simpletext sec cat of this category (related name ofsecondary_category)m2mcats (Reverse
ManyToManyFieldfromSimpleText) – All m2mcats of this category (related name ofcategories)
Methods
check(**kwargs)clean()Hook for doing any extra model-wide validation after clean() has been called on every field by self.clean_fields.
clean_fields([exclude])Clean all fields and raise a ValidationError containing a dict of all validation errors if any occur.
date_error_message(lookup_type, field_name, ...)delete(*args, **kwargs)Calling
deleteon a node will delete it as well as its full subtree, as opposed to reattaching all the subnodes to its parent node.from_db(db, field_names, values)full_clean([exclude, validate_unique])Call clean_fields(), clean(), and validate_unique() on the model.
get_absolute_url()Return a path.
get_ancestors([ascending, include_self])Creates a
QuerySetcontaining the ancestors of this model instance.get_children()Returns a
QuerySetcontaining the immediate children of this model instance, in tree order.get_deferred_fields()Return a set containing names of deferred fields for this instance.
get_descendant_count()Returns the number of descendants this model instance has.
get_descendants([include_self])Creates a
QuerySetcontaining descendants of this model instance, in tree order.get_family()Returns a
QuerySetcontaining the ancestors, the model itself and the descendants, in tree order.get_leafnodes([include_self])Creates a
QuerySetcontaining leafnodes of this model instance, in tree order.get_level()Returns the level of this node (distance from root)
get_next_sibling(*filter_args, **filter_kwargs)Returns this model instance's next sibling in the tree, or
Noneif it doesn't have a next sibling.get_previous_sibling(*filter_args, ...)Returns this model instance's previous sibling in the tree, or
Noneif it doesn't have a previous sibling.get_related_content_type(content_type)Get all related items of the specified content type.
get_relation_type(relation_type)Get all relations of the specified relation type.
get_root()Returns the root node of this model instance's tree.
get_siblings([include_self])Creates a
QuerySetcontaining siblings of this model instance.insert_at(target[, position, save, ...])Convenience method for calling
TreeManager.insert_nodewith this model instance.is_ancestor_of(other[, include_self])Returns
Trueif this model is an ancestor of the given node,Falseotherwise.is_child_node()Returns
Trueif this model instance is a child node,Falseotherwise.is_descendant_of(other[, include_self])Returns
Trueif this model is a descendant of the given node,Falseotherwise.is_leaf_node()Returns
Trueif this model instance is a leaf node (it has no children),Falseotherwise.is_root_node()Returns
Trueif this model instance is a root node,Falseotherwise.move_to(target[, position])Convenience method for calling
TreeManager.move_nodewith this model instance.prepare_database_save(field)refresh_from_db([using, fields])Reload field values from the database.
save(*args, **kwargs)Save the category.
save_base([raw, force_insert, force_update, ...])Handle the parts of saving which should be done only once per save, yet need to be done in raw saves, too.
serializable_value(field_name)Return the value of the field name for this instance.
unique_error_message(model_class, unique_check)validate_unique([exclude])Check unique constraints on the model and raise ValidationError if any failed.
Attributes
activeType:
BooleanFieldalternate_titleType:
CharFieldalternate_urlType:
CharFieldcategoryrelation_setType: Reverse
ForeignKeyfromCategoryRelationchildrenType: Reverse
TreeForeignKeyfromCategorydescriptionType:
TextFieldflatpage_setType: Reverse
ForeignKeyfromFlatPageidType:
AutoFieldlevelType:
PositiveIntegerFieldlftType:
PositiveIntegerFieldm2mcatsType: Reverse
ManyToManyFieldfromSimpleTextmeta_extraType:
TextFieldmeta_keywordsType:
CharFieldmore_catsType: Reverse
ManyToManyFieldfromFlatPagenameType:
CharFieldobjectsorderType:
IntegerFieldother_catsType: Reverse
ManyToManyFieldfromFlatPageparentType:
TreeForeignKeytoCategoryparent_idInternal field, use
parentinstead.pkrghtType:
PositiveIntegerFieldshort_titleReturn the name.
simpletext_sec_catType: Reverse
ForeignKeyfromSimpleTextsimpletext_setType: Reverse
ForeignKeyfromSimpleTextslugType:
SlugFieldthumbnailType:
FileFieldthumbnail_heightType:
IntegerFieldthumbnail_widthType:
IntegerFieldtreetree_idType:
PositiveIntegerField