mptt.admin

class mptt.admin.MPTTModelAdmin(model, admin_site)

A basic admin class that displays tree items according to their position in the tree. No extra editing functionality beyond what Django admin normally offers.

change_list_template = 'admin/mptt_change_list.html'
delete_selected_tree(modeladmin, request, queryset)

Deletes multiple instances and makes sure the MPTT fields get recalculated properly. (Because merely doing a bulk delete doesn’t trigger the post_delete hooks.)

form

alias of mptt.forms.MPTTAdminForm

formfield_for_foreignkey(db_field, request, **kwargs)

Get a form Field for a ForeignKey.

get_actions(request)

Return a dictionary mapping the names of all actions for this ModelAdmin to a tuple of (callable, name, description) for each action.

get_ordering(request)

Changes the default ordering for changelists to tree-order.

media
class mptt.admin.MPTTAdminForm(*args, **kwargs)

A form which validates that the chosen parent for a node isn’t one of its descendants.

base_fields = {}
clean()

Hook for doing any extra form-wide cleaning after Field.clean() has been called on every field. Any ValidationError raised by this method will not be associated with a particular field; it will have a special-case association with the field named ‘__all__’.

declared_fields = {}
media
class mptt.admin.DraggableMPTTAdmin(model, admin_site)

The DraggableMPTTAdmin modifies the standard Django administration change list to a drag-drop enabled interface.

change_list_template = None
changelist_view(request, *args, **kwargs)

The ‘change list’ admin view for this model.

expand_tree_by_default = False
get_data_before_update(request, cut_item, pasted_on)
get_move_node_change_message(request, cut_item, pasted_on, data_before_update)
indented_title(item)

Generate a short title for an object, indent it depending on the object’s depth in the hierarchy.

list_display = ('tree_actions', 'indented_title')
list_per_page = 2000
media
mptt_level_indent = 20
tree_actions(item)