doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
USE_X_SENDFILE When serving files, set the X-Sendfile header instead of serving the data with Flask. Some web servers, such as Apache, recognize this and serve the data more efficiently. This only makes sense when using such a server. Default: False
flask.config.index#USE_X_SENDFILE
uWSGI uWSGI is a deployment option on servers like nginx, lighttpd, and cherokee; see FastCGI and Standalone WSGI Containers for other options. To use your WSGI application with uWSGI protocol you will need a uWSGI server first. uWSGI is both a protocol and an application server; the application server can serve uWSGI,...
flask.deploying.uwsgi.index
class flask.views.View Alternative way to use view functions. A subclass has to implement dispatch_request() which is called with the view arguments from the URL routing system. If methods is provided the methods do not have to be passed to the add_url_rule() method explicitly: class MyView(View): methods = ['GET...
flask.api.index#flask.views.View
classmethod as_view(name, *class_args, **class_kwargs) Converts the class into an actual view function that can be used with the routing system. Internally this generates a function on the fly which will instantiate the View on each request and call the dispatch_request() method on it. The arguments passed to as_view...
flask.api.index#flask.views.View.as_view
decorators: List[Callable] = [] The canonical way to decorate class-based views is to decorate the return value of as_view(). However since this moves parts of the logic from the class declaration to the place where it’s hooked into the routing system. You can place one or more decorators in this list and whenever th...
flask.api.index#flask.views.View.decorators
dispatch_request() Subclasses have to override this method to implement the actual view function code. This method is called with all the arguments from the URL rule. Return type Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, None, None], Tuple[Union[Response, AnyStr, Dict[str, Any], Generator[AnyStr, No...
flask.api.index#flask.views.View.dispatch_request
methods: Optional[List[str]] = None A list of methods this view can handle.
flask.api.index#flask.views.View.methods
provide_automatic_options: Optional[bool] = None Setting this disables or force-enables the automatic options handling.
flask.api.index#flask.views.View.provide_automatic_options
flask.cli.with_appcontext(f) Wraps a callback so that it’s guaranteed to be executed with the script’s application context. If callbacks are registered directly to the app.cli object then they are wrapped with this function by default unless it’s disabled.
flask.api.index#flask.cli.with_appcontext
class flask.ctx._AppCtxGlobals A plain object. Used as a namespace for storing data during an application context. Creating an app context automatically creates this object, which is made available as the g proxy. 'key' in g Check whether an attribute is present. Changelog New in version 0.10. iter(g) Re...
flask.api.index#flask.ctx._AppCtxGlobals
get(name, default=None) Get an attribute by name, or a default value. Like dict.get(). Parameters name (str) – Name of attribute to get. default (Optional[Any]) – Value to return if the attribute is not present. Return type Any Changelog New in version 0.10.
flask.api.index#flask.ctx._AppCtxGlobals.get
pop(name, default=<object object>) Get and remove an attribute by name. Like dict.pop(). Parameters name (str) – Name of attribute to pop. default (Any) – Value to return if the attribute is not present, instead of raising a KeyError. Return type Any Changelog New in version 0.11.
flask.api.index#flask.ctx._AppCtxGlobals.pop
setdefault(name, default=None) Get the value of an attribute if it is present, otherwise set and return a default value. Like dict.setdefault(). Parameters name (str) – Name of attribute to get. default (Optional[Any]) – Value to set and return if the attribute is not present. Return type Any Changelog New...
flask.api.index#flask.ctx._AppCtxGlobals.setdefault
action(*, permissions=None, description=None) New in Django 3.2. This decorator can be used for setting specific attributes on custom action functions that can be used with actions: @admin.action( permissions=['publish'], description='Mark selected stories as published', ) def make_published(self, request, ...
django.ref.contrib.admin.actions#django.contrib.admin.action
class AdminSite(name='admin') A Django administrative site is represented by an instance of django.contrib.admin.sites.AdminSite; by default, an instance of this class is created as django.contrib.admin.site and you can register your models and ModelAdmin instances with it. If you want to customize the default admin ...
django.ref.contrib.admin.index#django.contrib.admin.AdminSite
AdminSite.add_action(action, name=None) Some actions are best if they’re made available to any object in the admin site – the export action defined above would be a good candidate. You can make an action globally available using AdminSite.add_action(). For example: from django.contrib import admin admin.site.add_act...
django.ref.contrib.admin.actions#django.contrib.admin.AdminSite.add_action
AdminSite.app_index_template Path to a custom template that will be used by the admin site app index view.
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.app_index_template
AdminSite.disable_action(name) If you need to disable a site-wide action you can call AdminSite.disable_action(). For example, you can use this method to remove the built-in “delete selected objects” action: admin.site.disable_action('delete_selected') Once you’ve done the above, that action will no longer be availa...
django.ref.contrib.admin.actions#django.contrib.admin.AdminSite.disable_action
AdminSite.each_context(request) Returns a dictionary of variables to put in the template context for every page in the admin site. Includes the following variables and values by default: site_header: AdminSite.site_header site_title: AdminSite.site_title site_url: AdminSite.site_url has_permission: AdminSite....
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.each_context
AdminSite.empty_value_display The string to use for displaying empty values in the admin site’s change list. Defaults to a dash. The value can also be overridden on a per ModelAdmin basis and on a custom field within a ModelAdmin by setting an empty_value_display attribute on the field. See ModelAdmin.empty_value_dis...
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.empty_value_display
AdminSite.enable_nav_sidebar A boolean value that determines whether to show the navigation sidebar on larger screens. By default, it is set to True.
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.enable_nav_sidebar
AdminSite.final_catch_all_view New in Django 3.2. A boolean value that determines whether to add a final catch-all view to the admin that redirects unauthenticated users to the login page. By default, it is set to True. Warning Setting this to False is not recommended as the view protects against a potential model...
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.final_catch_all_view
AdminSite.has_permission(request) Returns True if the user for the given HttpRequest has permission to view at least one page in the admin site. Defaults to requiring both User.is_active and User.is_staff to be True.
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.has_permission
AdminSite.index_template Path to a custom template that will be used by the admin site main index view.
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.index_template
AdminSite.index_title The text to put at the top of the admin index page (a string). By default, this is “Site administration”.
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.index_title
AdminSite.login_form Subclass of AuthenticationForm that will be used by the admin site login view.
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.login_form
AdminSite.login_template Path to a custom template that will be used by the admin site login view.
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.login_template
AdminSite.logout_template Path to a custom template that will be used by the admin site logout view.
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.logout_template
AdminSite.password_change_done_template Path to a custom template that will be used by the admin site password change done view.
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.password_change_done_template
AdminSite.password_change_template Path to a custom template that will be used by the admin site password change view.
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.password_change_template
AdminSite.register(model_or_iterable, admin_class=None, **options) Registers the given model class (or iterable of classes) with the given admin_class. admin_class defaults to ModelAdmin (the default admin options). If keyword arguments are given – e.g. list_display – they’ll be applied as options to the admin class....
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.register
AdminSite.site_header The text to put at the top of each admin page, as an <h1> (a string). By default, this is “Django administration”.
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.site_header
AdminSite.site_title The text to put at the end of each admin page’s <title> (a string). By default, this is “Django site admin”.
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.site_title
AdminSite.site_url The URL for the “View site” link at the top of each admin page. By default, site_url is /. Set it to None to remove the link. For sites running on a subpath, the each_context() method checks if the current request has request.META['SCRIPT_NAME'] set and uses that value if site_url isn’t set to some...
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.site_url
AdminSite.unregister(model_or_iterable) Unregisters the given model class (or iterable of classes). Raises django.contrib.admin.sites.NotRegistered if a model isn’t already registered.
django.ref.contrib.admin.index#django.contrib.admin.AdminSite.unregister
class apps.AdminConfig This is the default AppConfig class for the admin. It calls autodiscover() when Django starts.
django.ref.contrib.admin.index#django.contrib.admin.apps.AdminConfig
class apps.SimpleAdminConfig This class works like AdminConfig, except it doesn’t call autodiscover(). default_site A dotted import path to the default admin site’s class or to a callable that returns a site instance. Defaults to 'django.contrib.admin.sites.AdminSite'. See Overriding the default admin site for us...
django.ref.contrib.admin.index#django.contrib.admin.apps.SimpleAdminConfig
default_site A dotted import path to the default admin site’s class or to a callable that returns a site instance. Defaults to 'django.contrib.admin.sites.AdminSite'. See Overriding the default admin site for usage.
django.ref.contrib.admin.index#django.contrib.admin.apps.SimpleAdminConfig.default_site
autodiscover() This function attempts to import an admin module in each installed application. Such modules are expected to register models with the admin. Typically you won’t need to call this function directly as AdminConfig calls it when Django starts.
django.ref.contrib.admin.index#django.contrib.admin.autodiscover
display(*, boolean=None, ordering=None, description=None, empty_value=None) New in Django 3.2. This decorator can be used for setting specific attributes on custom display functions that can be used with list_display or readonly_fields: @admin.display( boolean=True, ordering='-publish_date', description...
django.ref.contrib.admin.index#django.contrib.admin.display
class InlineModelAdmin
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin
InlineModelAdmin.can_delete Specifies whether or not inline objects can be deleted in the inline. Defaults to True.
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.can_delete
InlineModelAdmin.classes A list or tuple containing extra CSS classes to apply to the fieldset that is rendered for the inlines. Defaults to None. As with classes configured in fieldsets, inlines with a collapse class will be initially collapsed and their header will have a small “show” link.
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.classes
InlineModelAdmin.extra This controls the number of extra forms the formset will display in addition to the initial forms. Defaults to 3. See the formsets documentation for more information. For users with JavaScript-enabled browsers, an “Add another” link is provided to enable any number of additional inlines to be a...
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.extra
InlineModelAdmin.fk_name The name of the foreign key on the model. In most cases this will be dealt with automatically, but fk_name must be specified explicitly if there are more than one foreign key to the same parent model.
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.fk_name
InlineModelAdmin.form The value for form defaults to ModelForm. This is what is passed through to inlineformset_factory() when creating the formset for this inline.
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.form
InlineModelAdmin.formset This defaults to BaseInlineFormSet. Using your own formset can give you many possibilities of customization. Inlines are built around model formsets.
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.formset
InlineModelAdmin.get_extra(request, obj=None, **kwargs) Returns the number of extra inline forms to use. By default, returns the InlineModelAdmin.extra attribute. Override this method to programmatically determine the number of extra inline forms. For example, this may be based on the model instance (passed as the ke...
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.get_extra
InlineModelAdmin.get_formset(request, obj=None, **kwargs) Returns a BaseInlineFormSet class for use in admin add/change views. obj is the parent object being edited or None when adding a new parent. See the example for ModelAdmin.get_formsets_with_inlines.
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.get_formset
InlineModelAdmin.get_max_num(request, obj=None, **kwargs) Returns the maximum number of extra inline forms to use. By default, returns the InlineModelAdmin.max_num attribute. Override this method to programmatically determine the maximum number of inline forms. For example, this may be based on the model instance (pa...
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.get_max_num
InlineModelAdmin.get_min_num(request, obj=None, **kwargs) Returns the minimum number of inline forms to use. By default, returns the InlineModelAdmin.min_num attribute. Override this method to programmatically determine the minimum number of inline forms. For example, this may be based on the model instance (passed a...
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.get_min_num
InlineModelAdmin.has_add_permission(request, obj) Should return True if adding an inline object is permitted, False otherwise. obj is the parent object being edited or None when adding a new parent.
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.has_add_permission
InlineModelAdmin.has_change_permission(request, obj=None) Should return True if editing an inline object is permitted, False otherwise. obj is the parent object being edited.
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.has_change_permission
InlineModelAdmin.has_delete_permission(request, obj=None) Should return True if deleting an inline object is permitted, False otherwise. obj is the parent object being edited.
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.has_delete_permission
InlineModelAdmin.max_num This controls the maximum number of forms to show in the inline. This doesn’t directly correlate to the number of objects, but can if the value is small enough. See Limiting the number of editable objects for more information. InlineModelAdmin.get_max_num() also allows you to customize the ma...
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.max_num
InlineModelAdmin.min_num This controls the minimum number of forms to show in the inline. See modelformset_factory() for more information. InlineModelAdmin.get_min_num() also allows you to customize the minimum number of displayed forms.
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.min_num
InlineModelAdmin.model The model which the inline is using. This is required.
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.model
InlineModelAdmin.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 ...
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.raw_id_fields
InlineModelAdmin.show_change_link Specifies whether or not inline objects that can be changed in the admin have a link to the change form. Defaults to False.
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.show_change_link
InlineModelAdmin.template The template used to render the inline on the page.
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.template
InlineModelAdmin.verbose_name An override to the verbose_name from the model’s inner Meta class.
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.verbose_name
InlineModelAdmin.verbose_name_plural An override to the verbose_name_plural from the model’s inner Meta class. If this isn’t given and the InlineModelAdmin.verbose_name is defined, Django will use InlineModelAdmin.verbose_name + 's'. Changed in Django 4.0: The fallback to InlineModelAdmin.verbose_name was added.
django.ref.contrib.admin.index#django.contrib.admin.InlineModelAdmin.verbose_name_plural
class ModelAdmin The ModelAdmin class is the representation of a model in the admin interface. Usually, these are stored in a file named admin.py in your application. Let’s take a look at an example of the ModelAdmin: from django.contrib import admin from myapp.models import Author class AuthorAdmin(admin.ModelAdmin...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin
ModelAdmin.actions A list of actions to make available on the change list page. See Admin actions for details.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.actions
ModelAdmin.actions_on_bottom Controls where on the page the actions bar appears. By default, the admin changelist displays actions at the top of the page (actions_on_top = True; actions_on_bottom = False).
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.actions_on_bottom
ModelAdmin.actions_on_top
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.actions_on_top
ModelAdmin.actions_selection_counter Controls whether a selection counter is displayed next to the action dropdown. By default, the admin changelist will display it (actions_selection_counter = True).
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.actions_selection_counter
ModelAdmin.add_form_template Path to a custom template, used by add_view().
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.add_form_template
ModelAdmin.add_view(request, form_url='', extra_context=None) Django view for the model instance addition page. See note below.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.add_view
ModelAdmin.autocomplete_fields autocomplete_fields is a list of ForeignKey and/or ManyToManyField fields you would like to change to Select2 autocomplete inputs. By default, the admin uses a select-box interface (<select>) for those fields. Sometimes you don’t want to incur the overhead of selecting all the related i...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.autocomplete_fields
ModelAdmin.change_form_template Path to a custom template, used by change_view().
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.change_form_template
ModelAdmin.change_list_template Path to a custom template, used by changelist_view().
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.change_list_template
ModelAdmin.change_view(request, object_id, form_url='', extra_context=None) Django view for the model instance editing page. See note below.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.change_view
ModelAdmin.changelist_view(request, extra_context=None) Django view for the model instances change list/actions page. See note below.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.changelist_view
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' You can also specify a field on a related model using the __ lookup, for example: date_hi...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.date_hierarchy
ModelAdmin.delete_confirmation_template Path to a custom template, used by delete_view() for displaying a confirmation page when deleting one or more objects.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.delete_confirmation_template
ModelAdmin.delete_model(request, obj) The delete_model method is given the HttpRequest and a model instance. Overriding this method allows doing pre- or post-delete operations. Call super().delete_model() to delete the object using Model.delete().
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.delete_model
ModelAdmin.delete_queryset(request, queryset) The delete_queryset() method is given the HttpRequest and a QuerySet of objects to be deleted. Override this method to customize the deletion process for the “delete selected objects” action.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.delete_queryset
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.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.delete_selected_confirmation_template
ModelAdmin.delete_view(request, object_id, extra_context=None) Django view for the model instance(s) deletion confirmation page. See note below.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.delete_view
ModelAdmin.empty_value_display 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 overri...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.empty_value_display
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 = mode...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.exclude
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.mo...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.fields
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 stri...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.fieldsets
ModelAdmin.filter_horizontal By default, a ManyToManyField is displayed in the admin site with a <select multiple>. However, multiple-select boxes can be difficult to use when selecting many items. Adding a ManyToManyField to this list will instead use a nifty unobtrusive JavaScript “filter” interface that allows sea...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.filter_horizontal
ModelAdmin.filter_vertical Same as filter_horizontal, but uses a vertical display of the filter interface with the box of unselected options appearing above the box of selected options.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.filter_vertical
ModelAdmin.form By default a ModelForm is dynamically created for your model. It is used to create the form presented on both the add/change pages. You can easily provide your own ModelForm to override any default form behavior on the add/change pages. Alternatively, you can customize the default form rather than spe...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.form
ModelAdmin.formfield_for_choice_field(db_field, request, **kwargs) Like the formfield_for_foreignkey and formfield_for_manytomany methods, the formfield_for_choice_field method can be overridden to change the default formfield for a field that has declared choices. For example, if the choices available to a superuser...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.formfield_for_choice_field
ModelAdmin.formfield_for_foreignkey(db_field, request, **kwargs) The formfield_for_foreignkey method on a ModelAdmin allows you to override the default formfield for a foreign keys field. For example, to return a subset of objects for this foreign key field based on the user: class MyModelAdmin(admin.ModelAdmin): ...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.formfield_for_foreignkey
ModelAdmin.formfield_for_manytomany(db_field, request, **kwargs) Like the formfield_for_foreignkey method, the formfield_for_manytomany method can be overridden to change the default formfield for a many to many field. For example, if an owner can own multiple cars and cars can belong to multiple owners – a many to m...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.formfield_for_manytomany
ModelAdmin.formfield_overrides This provides a quick-and-dirty way to override some of the Field options for use in the admin. formfield_overrides is a dictionary mapping a field class to a dict of arguments to pass to the field at construction time. Since that’s a bit abstract, let’s look at a concrete example. The ...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.formfield_overrides
ModelAdmin.get_actions(request) Finally, you can conditionally enable or disable actions on a per-request (and hence per-user basis) by overriding ModelAdmin.get_actions(). This returns a dictionary of actions allowed. The keys are action names, and the values are (function, name, short_description) tuples. For examp...
django.ref.contrib.admin.actions#django.contrib.admin.ModelAdmin.get_actions
ModelAdmin.get_autocomplete_fields(request) The get_autocomplete_fields() method is given the HttpRequest and is expected to return a list or tuple of field names that will be displayed with an autocomplete widget as described above in the ModelAdmin.autocomplete_fields section.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_autocomplete_fields
ModelAdmin.get_changeform_initial_data(request) A hook for the initial data on admin change forms. By default, fields are given initial values from GET parameters. For instance, ?name=initial_value will set the name field’s initial value to be initial_value. This method should return a dictionary in the form {'fieldn...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_changeform_initial_data
ModelAdmin.get_changelist(request, **kwargs) Returns the Changelist class to be used for listing. By default, django.contrib.admin.views.main.ChangeList is used. By inheriting this class you can change the behavior of the listing.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_changelist
ModelAdmin.get_changelist_form(request, **kwargs) Returns a ModelForm class for use in the Formset on the changelist page. To use a custom form, for example: from django import forms class MyForm(forms.ModelForm): pass class MyModelAdmin(admin.ModelAdmin): def get_changelist_form(self, request, **kwargs): ...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_changelist_form
ModelAdmin.get_changelist_formset(request, **kwargs) Returns a ModelFormSet class for use on the changelist page if list_editable is used. To use a custom formset, for example: from django.forms import BaseModelFormSet class MyAdminFormSet(BaseModelFormSet): pass class MyModelAdmin(admin.ModelAdmin): def ge...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_changelist_formset
ModelAdmin.get_deleted_objects(objs, request) A hook for customizing the deletion process of the delete_view() and the “delete selected” action. The objs argument is a homogeneous iterable of objects (a QuerySet or a list of model instances) to be deleted, and request is the HttpRequest. This method must return a 4-t...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_deleted_objects
ModelAdmin.get_exclude(request, obj=None) The get_exclude method is given the HttpRequest and the obj being edited (or None on an add form) and is expected to return a list of fields, as described in ModelAdmin.exclude.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_exclude
ModelAdmin.get_fields(request, obj=None) The get_fields method is given the HttpRequest and the obj being edited (or None on an add form) and is expected to return a list of fields, as described above in the ModelAdmin.fields section.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_fields