mptt.fields

Model fields for working with trees.

class mptt.fields.TreeForeignKey(to, on_delete=None, related_name=None, related_query_name=None, limit_choices_to=None, parent_link=False, to_field=None, db_constraint=True, **kwargs)

Extends the foreign key, but uses mptt’s TreeNodeChoiceField as the default form field.

This is useful if you are creating models that need automatically generated ModelForms to use the correct widgets.

formfield(**kwargs)

Use MPTT’s TreeNodeChoiceField

class mptt.fields.TreeOneToOneField(to, on_delete=None, to_field=None, **kwargs)
formfield(**kwargs)
class mptt.fields.TreeManyToManyField(to, related_name=None, related_query_name=None, limit_choices_to=None, symmetrical=None, through=None, through_fields=None, db_constraint=True, db_table=None, swappable=True, **kwargs)
formfield(**kwargs)