admin.ModelAdmin.save_related()

ModelAdmin.save_related(request, form, formsets, change) [source] The save_related method is 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. Here you can do any pre- or post-save operations for objects related to the parent. Note that at this point the parent object and its form have already been saved.

admin.ModelAdmin.save_on_top

ModelAdmin.save_on_top Set save_on_top to add save buttons across the top of your admin change forms. Normally, the save buttons appear only at the bottom of the forms. If you set save_on_top, the buttons will appear both on the top and the bottom. By default, save_on_top is set to False.

admin.ModelAdmin.save_model()

ModelAdmin.save_model(request, obj, form, change) [source] The save_model method is given the HttpRequest, a model instance, a ModelForm instance and a boolean value based on whether it is adding or changing the object. Here you can do any pre- or post-save operations. For example to attach request.user to the object prior to saving: from django.contrib import admin class ArticleAdmin(admin.ModelAdmin): def save_model(self, request, obj, form, change): obj.user = request.user

admin.ModelAdmin.save_formset()

ModelAdmin.save_formset(request, form, formset, change) [source] The save_formset method is given the HttpRequest, the parent ModelForm instance and a boolean value based on whether it is adding or changing the parent object. For example, to attach request.user to each changed formset model instance: class ArticleAdmin(admin.ModelAdmin): def save_formset(self, request, form, formset, change): instances = formset.save(commit=False) for obj in formset.deleted_objects:

admin.ModelAdmin.save_as_continue

ModelAdmin.save_as_continue New in Django 1.10. When save_as=True, the default redirect after saving the new object is to the change view for that object. If you set save_as_continue=False, the redirect will be to the changelist view. By default, save_as_continue is set to True.

admin.ModelAdmin.save_as

ModelAdmin.save_as Set save_as to enable a “save as new” feature on admin change forms. Normally, objects have three save options: “Save”, “Save and continue editing”, and “Save and add another”. If save_as is True, “Save and add another” will be replaced by a “Save as new” button that creates a new object (with a new ID) rather than updating the existing object. By default, save_as is set to False.

admin.ModelAdmin.response_delete()

ModelAdmin.response_delete(request, obj_display, obj_id) [source] Determines the HttpResponse for the delete_view() stage. response_delete is called after the object has been deleted. You can override it to change the default behavior after the object has been deleted. obj_display is a string with the name of the deleted object. obj_id is the serialized identifier used to retrieve the object to be deleted.

admin.ModelAdmin.response_change()

ModelAdmin.response_change(request, obj) [source] Determines the HttpResponse for the change_view() stage. response_change is called after the admin form is submitted and just after the object and all the related instances have been saved. You can override it to change the default behavior after the object has been changed.

admin.ModelAdmin.response_add()

ModelAdmin.response_add(request, obj, post_url_continue=None) [source] Determines the HttpResponse for the add_view() stage. response_add is called after the admin form is submitted and just after the object and all the related instances have been created and saved. You can override it to change the default behavior after the object has been created.

admin.ModelAdmin.readonly_fields

ModelAdmin.readonly_fields By default the admin shows all fields as editable. Any fields in this option (which should be a list or tuple) will display its data as-is and non-editable; they are also excluded from the ModelForm used for creating and editing. Note that when specifying ModelAdmin.fields or ModelAdmin.fieldsets the read-only fields must be present to be shown (they are ignored otherwise). If readonly_fields is used without defining explicit ordering through ModelAdmin.fields or M