categories.models.Category

Category#

class categories.models.Category(*args, **kwargs)[source]#

A basic category model.

Parameters:

Relationship fields:

Parameters:

parent (TreeForeignKey to Category) – Parent (related name: children)

Reverse relationships:

Parameters:
  • flatpage (Reverse ForeignKey from FlatPage) – All flat pages of this category (related name of category)

  • other_cats (Reverse ManyToManyField from FlatPage) – All other cats of this category (related name of other_categories)

  • more_cats (Reverse ManyToManyField from FlatPage) – All more cats of this category (related name of more_categories)

  • children (Reverse TreeForeignKey from Category) – All children of this category (related name of parent)

  • categoryrelation (Reverse ForeignKey from CategoryRelation) – All category relations of this category (related name of category)

  • simpletext (Reverse ForeignKey from SimpleText) – All Simple Text of this category (related name of primary_category)

  • simpletext_sec_cat (Reverse ForeignKey from SimpleText) – All simpletext sec cat of this category (related name of secondary_category)

  • m2mcats (Reverse ManyToManyField from SimpleText) – All m2mcats of this category (related name of categories)

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 delete on 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 QuerySet containing the ancestors of this model instance.

get_children()

Returns a QuerySet containing 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 QuerySet containing descendants of this model instance, in tree order.

get_family()

Returns a QuerySet containing the ancestors, the model itself and the descendants, in tree order.

get_leafnodes([include_self])

Creates a QuerySet containing 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 None if it doesn't have a next sibling.

get_previous_sibling(*filter_args, ...)

Returns this model instance's previous sibling in the tree, or None if 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 QuerySet containing siblings of this model instance.

insert_at(target[, position, save, ...])

Convenience method for calling TreeManager.insert_node with this model instance.

is_ancestor_of(other[, include_self])

Returns True if this model is an ancestor of the given node, False otherwise.

is_child_node()

Returns True if this model instance is a child node, False otherwise.

is_descendant_of(other[, include_self])

Returns True if this model is a descendant of the given node, False otherwise.

is_leaf_node()

Returns True if this model instance is a leaf node (it has no children), False otherwise.

is_root_node()

Returns True if this model instance is a root node, False otherwise.

move_to(target[, position])

Convenience method for calling TreeManager.move_node with 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

active

Type: BooleanField

alternate_title

Type: CharField

alternate_url

Type: CharField

categoryrelation_set

Type: Reverse ForeignKey from CategoryRelation

children

Type: Reverse TreeForeignKey from Category

description

Type: TextField

flatpage_set

Type: Reverse ForeignKey from FlatPage

id

Type: AutoField

level

Type: PositiveIntegerField

lft

Type: PositiveIntegerField

m2mcats

Type: Reverse ManyToManyField from SimpleText

meta_extra

Type: TextField

meta_keywords

Type: CharField

more_cats

Type: Reverse ManyToManyField from FlatPage

name

Type: CharField

objects

order

Type: IntegerField

other_cats

Type: Reverse ManyToManyField from FlatPage

parent

Type: TreeForeignKey to Category

parent_id

Internal field, use parent instead.

pk

rght

Type: PositiveIntegerField

short_title

Return the name.

simpletext_sec_cat

Type: Reverse ForeignKey from SimpleText

simpletext_set

Type: Reverse ForeignKey from SimpleText

slug

Type: SlugField

thumbnail

Type: FileField

thumbnail_height

Type: IntegerField

thumbnail_width

Type: IntegerField

tree

tree_id

Type: PositiveIntegerField