# `mptt.fields`

Model fields for working with trees.

class `mptt.fields.``TreeForeignKey`(to, to_field=None, rel_class=<class 'django.db.models.fields.related.ManyToOneRel'>, 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, to_field=None, **kwargs)
  `formfield`(**kwargs)

class `mptt.fields.``TreeManyToManyField`(to, db_constraint=True, swappable=True, **kwargs)
  `formfield`(**kwargs)