admin.ModelAdmin.prepopulated_fields

ModelAdmin.prepopulated_fields Set prepopulated_fields to a dictionary mapping field names to the fields it should prepopulate from: class ArticleAdmin(admin.ModelAdmin): prepopulated_fields = {"slug": ("title",)} When set, the given fields will use a bit of JavaScript to populate from the fields assigned. The main use for this functionality is to automatically generate the value for SlugField fields from one or more other fields. The generated value is produced by concatenating the val

admin.ModelAdmin.radio_fields

ModelAdmin.radio_fields By default, Django’s admin uses a select-box interface (<select>) for fields that are ForeignKey or have choices set. If a field is present in radio_fields, Django will use a radio-button interface instead. Assuming group is a ForeignKey on the Person model: class PersonAdmin(admin.ModelAdmin): radio_fields = {"group": admin.VERTICAL} You have the choice of using HORIZONTAL or VERTICAL from the django.contrib.admin module. Don’t include a field in radio_fie

admin.ModelAdmin.raw_id_fields

ModelAdmin.raw_id_fields By default, Django’s admin uses a select-box interface (<select>) for fields that are ForeignKey. Sometimes you don’t want to incur the overhead of having to select all the related instances to display in the drop-down. raw_id_fields is a list of fields you would like to change into an Input widget for either a ForeignKey or ManyToManyField: class ArticleAdmin(admin.ModelAdmin): raw_id_fields = ("newspaper",) The raw_id_fields Input widget should contain a

admin.ModelAdmin.preserve_filters

ModelAdmin.preserve_filters The admin now preserves filters on the list view after creating, editing or deleting an object. You can restore the previous behavior of clearing filters by setting this attribute to False.

admin.ModelAdmin.message_user()

ModelAdmin.message_user(request, message, level=messages.INFO, extra_tags='', fail_silently=False) [source] Sends a message to the user using the django.contrib.messages backend. See the custom ModelAdmin example. Keyword arguments allow you to change the message level, add extra CSS tags, or fail silently if the contrib.messages framework is not installed. These keyword arguments match those for django.contrib.messages.add_message(), see that function’s documentation for more details. One d

admin.ModelAdmin.object_history_template

ModelAdmin.object_history_template Path to a custom template, used by history_view().

admin.ModelAdmin.ordering

ModelAdmin.ordering Set ordering to specify how lists of objects should be ordered in the Django admin views. This should be a list or tuple in the same format as a model’s ordering parameter. If this isn’t provided, the Django admin will use the model’s default ordering. If you need to specify a dynamic order (for example depending on user or language) you can implement a get_ordering() method.

admin.ModelAdmin.paginator

ModelAdmin.paginator The paginator class to be used for pagination. By default, django.core.paginator.Paginator is used. If the custom paginator class doesn’t have the same constructor interface as django.core.paginator.Paginator, you will also need to provide an implementation for ModelAdmin.get_paginator().

admin.ModelAdmin.list_select_related

ModelAdmin.list_select_related Set list_select_related to tell Django to use select_related() in retrieving the list of objects on the admin change list page. This can save you a bunch of database queries. The value should be either a boolean, a list or a tuple. Default is False. When value is True, select_related() will always be called. When value is set to False, Django will look at list_display and call select_related() if any ForeignKey is present. If you need more fine-grained control,

admin.ModelAdmin.list_max_show_all

ModelAdmin.list_max_show_all Set list_max_show_all to control how many items can appear on a “Show all” admin change list page. The admin will display a “Show all” link on the change list only if the total result count is less than or equal to this setting. By default, this is set to 200.