categories.base.CategoryBase
CategoryBase#
- class categories.base.CategoryBase(*args, **kwargs)[source]#
This base model includes the absolute bare-bones fields and methods.
One could simply subclass this model, do nothing else, and it should work.
- Parameters:
name (CharField) – Name
slug (SlugField) – Slug
active (BooleanField) – Active
Relationship fields:
- Parameters:
parent (
TreeForeignKeytoCategoryBase) – Parent
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_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_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:
BooleanFieldnameType:
CharFieldobjectsparentType:
TreeForeignKeytoCategoryBaseparent_idInternal field, use
parentinstead.pkslugType:
SlugFieldtree