class documentation

Encapsulate all admin options and functionality for a given model.

Method __init__ Undocumented
Method __repr__ Undocumented
Method __str__ Undocumented
Method action_checkbox A list_display column containing a checkbox widget.
Method add_view Undocumented
Method change_view Undocumented
Method changeform_view Undocumented
Method changelist_view The 'change list' admin view for this model.
Method construct_change_message Construct a JSON structure describing changes from a changed object.
Method delete_model Given a model instance delete it from the database.
Method delete_queryset Given a queryset, delete it from the database.
Method delete_view Undocumented
Method get_action Return a given action from a parameter, which can either be a callable, or the name of a method on the ModelAdmin. Return is a tuple of (callable, name, description).
Method get_action_choices Return a list of choices for use in a form object. Each choice is a tuple (name, description).
Method get_actions Return a dictionary mapping the names of all actions for this ModelAdmin to a tuple of (callable, name, description) for each action.
Method get_changeform_initial_data Get the initial form data from the request's GET params.
Method get_changelist Return the ChangeList class for use on the changelist page.
Method get_changelist_form Return a Form class for use in the Formset on the changelist page.
Method get_changelist_formset Return a FormSet class for use on the changelist page if list_editable is used.
Method get_changelist_instance Return a `ChangeList` instance based on `request`. May raise `IncorrectLookupParameters`.
Method get_deleted_objects Hook for customizing the delete process for the delete view and the "delete selected" action.
Method get_form Return a Form class for use in the admin add view. This is used by add_view and change_view.
Method get_formset_kwargs Undocumented
Method get_formsets_with_inlines Yield formsets and the corresponding inlines.
Method get_inline_formsets Undocumented
Method get_inline_instances Undocumented
Method get_list_display Return a sequence containing the fields to be displayed on the changelist.
Method get_list_display_links Return a sequence containing the fields to be displayed as links on the changelist. The list_display parameter is the list of fields returned by get_list_display().
Method get_list_filter Return a sequence containing the fields to be displayed as filters in the right sidebar of the changelist page.
Method get_list_select_related Return a list of fields to add to the select_related() part of the changelist items query.
Method get_model_perms Return a dict of all perms for this model. This dict has the keys ``add``, ``change``, ``delete``, and ``view`` mapping to the True/False for each of those actions.
Method get_object Return an instance matching the field and value provided, the primary key is used if no field is provided. Return ``None`` if no match is found or the object_id fails validation.
Method get_paginator Undocumented
Method get_preserved_filters Return the preserved filters querystring.
Method get_search_fields Return a sequence containing the fields to be searched whenever somebody submits a search query.
Method get_search_results Return a tuple containing a queryset to implement the search and a boolean indicating if the results may contain duplicates.
Method get_urls Undocumented
Method history_view The 'history' admin view for this model.
Method log_addition Log that an object has been successfully added.
Method log_change Log that an object has been successfully changed.
Method log_deletion Log that an object will be deleted. Note that this method must be called before the deletion.
Method message_user Send a message to the user. The default implementation posts a message using the django.contrib.messages backend.
Method render_change_form Undocumented
Method render_delete_form Undocumented
Method response_action Handle an admin action. This is called if a request is POSTed to the changelist; it returns an HttpResponse if the action was handled, and None otherwise.
Method response_add Determine the HttpResponse for the add_view stage.
Method response_change Determine the HttpResponse for the change_view stage.
Method response_delete Determine the HttpResponse for the delete_view stage.
Method response_post_save_add Figure out where to redirect after the 'Save' button has been pressed when adding a new object.
Method response_post_save_change Figure out where to redirect after the 'Save' button has been pressed when editing an existing object.
Method save_form Given a ModelForm return an unsaved instance. ``change`` is True if the object is being changed, and False if it's being added.
Method save_formset Given an inline formset save it to the database.
Method save_model Given a model instance save it to the database.
Method save_related Given the ``HttpRequest``, the parent ``ModelForm`` instance, the list of inline formsets and a boolean value based on whether the parent is being added or changed, save the related objects to the database...
Class Variable actions Undocumented
Class Variable actions_on_bottom Undocumented
Class Variable actions_on_top Undocumented
Class Variable actions_selection_counter Undocumented
Class Variable add_form_template Undocumented
Class Variable change_form_template Undocumented
Class Variable change_list_template Undocumented
Class Variable date_hierarchy Undocumented
Class Variable delete_confirmation_template Undocumented
Class Variable delete_selected_confirmation_template Undocumented
Class Variable inlines Undocumented
Class Variable list_display Undocumented
Class Variable list_display_links Undocumented
Class Variable list_editable Undocumented
Class Variable list_filter Undocumented
Class Variable list_max_show_all Undocumented
Class Variable list_per_page Undocumented
Class Variable list_select_related Undocumented
Class Variable object_history_template Undocumented
Class Variable popup_response_template Undocumented
Class Variable preserve_filters Undocumented
Class Variable save_as Undocumented
Class Variable save_as_continue Undocumented
Class Variable save_on_top Undocumented
Class Variable search_fields Undocumented
Class Variable search_help_text Undocumented
Instance Variable admin_site Undocumented
Instance Variable model Undocumented
Instance Variable opts Undocumented
Property media Undocumented
Property urls Undocumented
Static Method _get_action_description Undocumented
Method _changeform_view Undocumented
Method _create_formsets Helper function to generate formsets for add/change_view.
Method _delete_view The 'delete' admin view for this model.
Method _filter_actions_by_permissions Filter out any actions that the user doesn't have access to.
Method _get_base_actions Return the list of actions, prior to any request-based filtering.
Method _get_edited_object_pks Return POST data values of list_editable primary keys.
Method _get_form_for_get_fields Undocumented
Method _get_list_editable_queryset Based on POST data, return a queryset of the objects that were edited via list_editable.
Method _get_obj_does_not_exist_redirect Create a message informing the user that the object doesn't exist and return a redirect to the admin index page.
Method _response_post_save Undocumented

Inherited from BaseModelAdmin:

Method check Undocumented
Method formfield_for_choice_field Get a form Field for a database Field that has declared choices.
Method formfield_for_dbfield Hook for specifying the form Field instance for a given database Field instance.
Method formfield_for_foreignkey Get a form Field for a ForeignKey.
Method formfield_for_manytomany Get a form Field for a ManyToManyField.
Method get_autocomplete_fields Return a list of ForeignKey and/or ManyToMany fields which should use an autocomplete widget.
Method get_empty_value_display Return the empty_value_display set on ModelAdmin or AdminSite.
Method get_exclude Hook for specifying exclude.
Method get_field_queryset If the ModelAdmin specifies ordering, the queryset should respect that ordering. Otherwise don't specify the queryset, let the field decide (return None in that case).
Method get_fields Hook for specifying fields.
Method get_fieldsets Hook for specifying fieldsets.
Method get_inlines Hook for specifying custom inlines.
Method get_ordering Hook for specifying field ordering.
Method get_prepopulated_fields Hook for specifying custom prepopulated fields.
Method get_queryset Return a QuerySet of all model instances that can be edited by the admin site. This is used by changelist_view.
Method get_readonly_fields Hook for specifying custom readonly fields.
Method get_sortable_by Hook for specifying which fields can be sorted in the changelist.
Method get_view_on_site_url Undocumented
Method has_add_permission Return True if the given request has permission to add an object. Can be overridden by the user in subclasses.
Method has_change_permission Return True if the given request has permission to change the given Django model instance, the default implementation doesn't examine the `obj` parameter.
Method has_delete_permission Return True if the given request has permission to change the given Django model instance, the default implementation doesn't examine the `obj` parameter.
Method has_module_permission Return True if the given request has any permission in the given app label.
Method has_view_or_change_permission Undocumented
Method has_view_permission Return True if the given request has permission to view the given Django model instance. The default implementation doesn't examine the `obj` parameter.
Method lookup_allowed Undocumented
Method to_field_allowed Return True if the model associated with this admin should be allowed to be referenced by the specified field.
Class Variable autocomplete_fields Undocumented
Class Variable exclude Undocumented
Class Variable fields Undocumented
Class Variable fieldsets Undocumented
Class Variable filter_horizontal Undocumented
Class Variable filter_vertical Undocumented
Class Variable ordering Undocumented
Class Variable prepopulated_fields Undocumented
Class Variable radio_fields Undocumented
Class Variable raw_id_fields Undocumented
Class Variable readonly_fields Undocumented
Class Variable show_full_result_count Undocumented
Class Variable sortable_by Undocumented
Class Variable view_on_site Undocumented
Instance Variable formfield_overrides Undocumented
def __init__(self, model, admin_site): (source)
def __repr__(self): (source)

Undocumented

def __str__(self): (source)

Undocumented

@display(description=mark_safe('<input type="checkbox" id="action-toggle">'))
def action_checkbox(self, obj): (source)

A list_display column containing a checkbox widget.

def add_view(self, request, form_url='', extra_context=None): (source)

Undocumented

def change_view(self, request, object_id, form_url='', extra_context=None): (source)

Undocumented

@csrf_protect_m
def changeform_view(self, request, object_id=None, form_url='', extra_context=None): (source)

Undocumented

@csrf_protect_m
def changelist_view(self, request, extra_context=None): (source)

The 'change list' admin view for this model.

def construct_change_message(self, request, form, formsets, add=False): (source)

Construct a JSON structure describing changes from a changed object.

def delete_model(self, request, obj): (source)

Given a model instance delete it from the database.

def delete_queryset(self, request, queryset): (source)

Given a queryset, delete it from the database.

@csrf_protect_m
def delete_view(self, request, object_id, extra_context=None): (source)

Undocumented

def get_action(self, action): (source)

Return a given action from a parameter, which can either be a callable, or the name of a method on the ModelAdmin. Return is a tuple of (callable, name, description).

def get_action_choices(self, request, default_choices=models.BLANK_CHOICE_DASH): (source)

Return a list of choices for use in a form object. Each choice is a tuple (name, description).

def get_actions(self, request): (source)

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

def get_changeform_initial_data(self, request): (source)

Get the initial form data from the request's GET params.

def get_changelist(self, request, **kwargs): (source)

Return the ChangeList class for use on the changelist page.

def get_changelist_form(self, request, **kwargs): (source)

Return a Form class for use in the Formset on the changelist page.

def get_changelist_formset(self, request, **kwargs): (source)

Return a FormSet class for use on the changelist page if list_editable is used.

def get_changelist_instance(self, request): (source)

Return a `ChangeList` instance based on `request`. May raise `IncorrectLookupParameters`.

def get_deleted_objects(self, objs, request): (source)

Hook for customizing the delete process for the delete view and the "delete selected" action.

def get_form(self, request, obj=None, change=False, **kwargs): (source)

Return a Form class for use in the admin add view. This is used by add_view and change_view.

def get_formset_kwargs(self, request, obj, inline, prefix): (source)

Undocumented

def get_formsets_with_inlines(self, request, obj=None): (source)

Yield formsets and the corresponding inlines.

def get_inline_formsets(self, request, formsets, inline_instances, obj=None): (source)

Undocumented

def get_inline_instances(self, request, obj=None): (source)

Undocumented

def get_list_display(self, request): (source)

Return a sequence containing the fields to be displayed on the changelist.

def get_list_display_links(self, request, list_display): (source)

Return a sequence containing the fields to be displayed as links on the changelist. The list_display parameter is the list of fields returned by get_list_display().

def get_list_filter(self, request): (source)

Return a sequence containing the fields to be displayed as filters in the right sidebar of the changelist page.

def get_list_select_related(self, request): (source)

Return a list of fields to add to the select_related() part of the changelist items query.

def get_model_perms(self, request): (source)

Return a dict of all perms for this model. This dict has the keys ``add``, ``change``, ``delete``, and ``view`` mapping to the True/False for each of those actions.

def get_object(self, request, object_id, from_field=None): (source)

Return an instance matching the field and value provided, the primary key is used if no field is provided. Return ``None`` if no match is found or the object_id fails validation.

def get_paginator(self, request, queryset, per_page, orphans=0, allow_empty_first_page=True): (source)

Undocumented

def get_preserved_filters(self, request): (source)

Return the preserved filters querystring.

def get_search_fields(self, request): (source)

Return a sequence containing the fields to be searched whenever somebody submits a search query.

def get_search_results(self, request, queryset, search_term): (source)

Return a tuple containing a queryset to implement the search and a boolean indicating if the results may contain duplicates.

def get_urls(self): (source)

Undocumented

def history_view(self, request, object_id, extra_context=None): (source)

The 'history' admin view for this model.

def log_addition(self, request, obj, message): (source)

Log that an object has been successfully added. The default implementation creates an admin LogEntry object.

def log_change(self, request, obj, message): (source)

Log that an object has been successfully changed. The default implementation creates an admin LogEntry object.

def log_deletion(self, request, obj, object_repr): (source)

Log that an object will be deleted. Note that this method must be called before the deletion. The default implementation creates an admin LogEntry object.

def message_user(self, request, message, level=messages.INFO, extra_tags='', fail_silently=False): (source)

Send a message to the user. The default implementation posts a message using the django.contrib.messages backend. Exposes almost the same API as messages.add_message(), but accepts the positional arguments in a different order to maintain backwards compatibility. For convenience, it accepts the `level` argument as a string rather than the usual level number.

def render_change_form(self, request, context, add=False, change=False, form_url='', obj=None): (source)

Undocumented

def render_delete_form(self, request, context): (source)

Undocumented

def response_action(self, request, queryset): (source)

Handle an admin action. This is called if a request is POSTed to the changelist; it returns an HttpResponse if the action was handled, and None otherwise.

def response_add(self, request, obj, post_url_continue=None): (source)

Determine the HttpResponse for the add_view stage.

def response_change(self, request, obj): (source)

Determine the HttpResponse for the change_view stage.

def response_delete(self, request, obj_display, obj_id): (source)

Determine the HttpResponse for the delete_view stage.

def response_post_save_add(self, request, obj): (source)

Figure out where to redirect after the 'Save' button has been pressed when adding a new object.

def response_post_save_change(self, request, obj): (source)

Figure out where to redirect after the 'Save' button has been pressed when editing an existing object.

def save_form(self, request, form, change): (source)

Given a ModelForm return an unsaved instance. ``change`` is True if the object is being changed, and False if it's being added.

def save_formset(self, request, form, formset, change): (source)

Given an inline formset save it to the database.

def save_model(self, request, obj, form, change): (source)

Given a model instance save it to the database.

def save_related(self, request, form, formsets, change): (source)

Given the ``HttpRequest``, the parent ``ModelForm`` instance, the list of inline formsets and a boolean value based on whether the parent is being added or changed, save the related objects to the database. Note that at this point save_form() and save_model() have already been called.

Undocumented

actions_on_bottom: bool = (source)

Undocumented

actions_on_top: bool = (source)

Undocumented

actions_selection_counter: bool = (source)

Undocumented

add_form_template = (source)

Undocumented

change_form_template = (source)

Undocumented

change_list_template = (source)

Undocumented

date_hierarchy = (source)

Undocumented

delete_confirmation_template = (source)

Undocumented

delete_selected_confirmation_template = (source)

Undocumented

Undocumented

list_display_links: tuple = (source)

Undocumented

list_editable: tuple = (source)

Undocumented

list_max_show_all: int = (source)

Undocumented

list_per_page: int = (source)

Undocumented

list_select_related: bool = (source)

Undocumented

object_history_template = (source)

Undocumented

popup_response_template = (source)

Undocumented

preserve_filters: bool = (source)

Undocumented

Undocumented

save_as_continue: bool = (source)

Undocumented

save_on_top: bool = (source)

Undocumented

search_help_text = (source)

Undocumented

admin_site = (source)

Undocumented

Undocumented

Undocumented

Undocumented

@staticmethod
def _get_action_description(func, name): (source)

Undocumented

def _changeform_view(self, request, object_id, form_url, extra_context): (source)

Undocumented

def _create_formsets(self, request, obj, change): (source)

Helper function to generate formsets for add/change_view.

def _delete_view(self, request, object_id, extra_context): (source)

The 'delete' admin view for this model.

def _filter_actions_by_permissions(self, request, actions): (source)

Filter out any actions that the user doesn't have access to.

def _get_base_actions(self): (source)

Return the list of actions, prior to any request-based filtering.

def _get_edited_object_pks(self, request, prefix): (source)

Return POST data values of list_editable primary keys.

def _get_form_for_get_fields(self, request, obj): (source)

Undocumented

def _get_list_editable_queryset(self, request, prefix): (source)

Based on POST data, return a queryset of the objects that were edited via list_editable.

def _get_obj_does_not_exist_redirect(self, request, opts, object_id): (source)

Create a message informing the user that the object doesn't exist and return a redirect to the admin index page.

def _response_post_save(self, request, obj): (source)

Undocumented