admin.ModelAdmin.fieldsets

ModelAdmin.fieldsets Set fieldsets to control the layout of admin “add” and “change” pages. fieldsets is a list of two-tuples, in which each two-tuple represents a <fieldset> on the admin form page. (A <fieldset> is a “section” of the form.) The two-tuples are in the format (name, field_options), where name is a string representing the title of the fieldset and field_options is a dictionary of information about the fieldset, including a list of fields to be displayed in it. A ful

admin.ModelAdmin.fields

ModelAdmin.fields Use the fields option to make simple layout changes in the forms on the “add” and “change” pages such as showing only a subset of available fields, modifying their order, or grouping them into rows. For example, you could define a simpler version of the admin form for the django.contrib.flatpages.models.FlatPage model as follows: class FlatPageAdmin(admin.ModelAdmin): fields = ('url', 'title', 'content') In the above example, only the fields url, title and content will

admin.ModelAdmin.exclude

ModelAdmin.exclude This attribute, if given, should be a list of field names to exclude from the form. For example, let’s consider the following model: from django.db import models class Author(models.Model): name = models.CharField(max_length=100) title = models.CharField(max_length=3) birth_date = models.DateField(blank=True, null=True) If you want a form for the Author model that includes only the name and title fields, you would specify fields or exclude like this: from dja

admin.ModelAdmin.empty_value_display

ModelAdmin.empty_value_display New in Django 1.9. This attribute overrides the default display value for record’s fields that are empty (None, empty string, etc.). The default value is - (a dash). For example: from django.contrib import admin class AuthorAdmin(admin.ModelAdmin): empty_value_display = '-empty-' You can also override empty_value_display for all admin pages with AdminSite.empty_value_display, or for specific fields like this: from django.contrib import admin class Auth

admin.ModelAdmin.delete_view()

ModelAdmin.delete_view(request, object_id, extra_context=None) [source] Django view for the model instance(s) deletion confirmation page. See note below.

admin.ModelAdmin.delete_selected_confirmation_template

ModelAdmin.delete_selected_confirmation_template Path to a custom template, used by the delete_selected action method for displaying a confirmation page when deleting one or more objects. See the actions documentation.

admin.ModelAdmin.delete_model()

ModelAdmin.delete_model(request, obj) [source] The delete_model method is given the HttpRequest and a model instance. Use this method to do pre- or post-delete operations.

admin.ModelAdmin.delete_confirmation_template

ModelAdmin.delete_confirmation_template Path to a custom template, used by delete_view() for displaying a confirmation page when deleting one or more objects.

admin.ModelAdmin.date_hierarchy

ModelAdmin.date_hierarchy Set date_hierarchy to the name of a DateField or DateTimeField in your model, and the change list page will include a date-based drilldown navigation by that field. Example: date_hierarchy = 'pub_date' This will intelligently populate itself based on available data, e.g. if all the dates are in one month, it’ll show the day-level drill-down only. Note date_hierarchy uses QuerySet.datetimes() internally. Please refer to its documentation for some caveats when time

admin.ModelAdmin.change_view()

ModelAdmin.change_view(request, object_id, form_url='', extra_context=None) [source] Django view for the model instance editing page. See note below.