doc_content
stringlengths
1
386k
doc_id
stringlengths
5
188
ModelAdmin.get_fieldsets(request, obj=None) The get_fieldsets method is given the HttpRequest and the obj being edited (or None on an add form) and is expected to return a list of two-tuples, in which each two-tuple represents a <fieldset> on the admin form page, as described above in the ModelAdmin.fieldsets section...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_fieldsets
ModelAdmin.get_form(request, obj=None, **kwargs) Returns a ModelForm class for use in the admin add and change views, see add_view() and change_view(). The base implementation uses modelform_factory() to subclass form, modified by attributes such as fields and exclude. So, for example, if you wanted to offer addition...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_form
ModelAdmin.get_formset_kwargs(request, obj, inline, prefix) New in Django 4.0. A hook for customizing the keyword arguments passed to the constructor of a formset. For example, to pass request to formset forms: class MyModelAdmin(admin.ModelAdmin): def get_formset_kwargs(self, request, obj, inline, prefix): ...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_formset_kwargs
ModelAdmin.get_formsets_with_inlines(request, obj=None) Yields (FormSet, InlineModelAdmin) pairs for use in admin add and change views. For example if you wanted to display a particular inline only in the change view, you could override get_formsets_with_inlines as follows: class MyModelAdmin(admin.ModelAdmin): i...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_formsets_with_inlines
ModelAdmin.get_inline_instances(request, obj=None) The get_inline_instances method is given the HttpRequest and the obj being edited (or None on an add form) and is expected to return a list or tuple of InlineModelAdmin objects, as described below in the InlineModelAdmin section. For example, the following would retu...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_inline_instances
ModelAdmin.get_inlines(request, obj) The get_inlines method is given the HttpRequest and the obj being edited (or None on an add form) and is expected to return an iterable of inlines. You can override this method to dynamically add inlines based on the request or model instance instead of specifying them in ModelAdm...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_inlines
ModelAdmin.get_list_display(request) The get_list_display method is given the HttpRequest and is expected to return a list or tuple of field names that will be displayed on the changelist view as described above in the ModelAdmin.list_display section.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_list_display
ModelAdmin.get_list_display_links(request, list_display) The get_list_display_links method is given the HttpRequest and the list or tuple returned by ModelAdmin.get_list_display(). It is expected to return either None or a list or tuple of field names on the changelist that will be linked to the change view, as descr...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_list_display_links
ModelAdmin.get_list_filter(request) The get_list_filter method is given the HttpRequest and is expected to return the same kind of sequence type as for the list_filter attribute.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_list_filter
ModelAdmin.get_list_select_related(request) The get_list_select_related method is given the HttpRequest and should return a boolean or list as ModelAdmin.list_select_related does.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_list_select_related
ModelAdmin.get_ordering(request) The get_ordering method takes a request as parameter and is expected to return a list or tuple for ordering similar to the ordering attribute. For example: class PersonAdmin(admin.ModelAdmin): def get_ordering(self, request): if request.user.is_superuser: retu...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_ordering
ModelAdmin.get_paginator(request, queryset, per_page, orphans=0, allow_empty_first_page=True) Returns an instance of the paginator to use for this view. By default, instantiates an instance of paginator.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_paginator
ModelAdmin.get_prepopulated_fields(request, obj=None) The get_prepopulated_fields method is given the HttpRequest and the obj being edited (or None on an add form) and is expected to return a dictionary, as described above in the ModelAdmin.prepopulated_fields section.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_prepopulated_fields
ModelAdmin.get_queryset(request) The get_queryset method on a ModelAdmin returns a QuerySet of all model instances that can be edited by the admin site. One use case for overriding this method is to show objects owned by the logged-in user: class MyModelAdmin(admin.ModelAdmin): def get_queryset(self, request): ...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_queryset
ModelAdmin.get_readonly_fields(request, obj=None) The get_readonly_fields method is given the HttpRequest and the obj being edited (or None on an add form) and is expected to return a list or tuple of field names that will be displayed as read-only, as described above in the ModelAdmin.readonly_fields section.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_readonly_fields
ModelAdmin.get_search_fields(request) The get_search_fields method is given the HttpRequest and is expected to return the same kind of sequence type as for the search_fields attribute.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_search_fields
ModelAdmin.get_search_results(request, queryset, search_term) The get_search_results method modifies the list of objects displayed into those that match the provided search term. It accepts the request, a queryset that applies the current filters, and the user-provided search term. It returns a tuple containing a que...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_search_results
ModelAdmin.get_sortable_by(request) The get_sortable_by() method is passed the HttpRequest and is expected to return a collection (e.g. list, tuple, or set) of field names that will be sortable in the change list page. Its default implementation returns sortable_by if it’s set, otherwise it defers to get_list_display...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_sortable_by
ModelAdmin.get_urls() The get_urls method on a ModelAdmin returns the URLs to be used for that ModelAdmin in the same way as a URLconf. Therefore you can extend them as documented in URL dispatcher: from django.contrib import admin from django.template.response import TemplateResponse from django.urls import path cl...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.get_urls
ModelAdmin.has_add_permission(request) Should return True if adding an object is permitted, False otherwise.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.has_add_permission
ModelAdmin.has_change_permission(request, obj=None) Should return True if editing obj is permitted, False otherwise. If obj is None, should return True or False to indicate whether editing of objects of this type is permitted in general (e.g., False will be interpreted as meaning that the current user is not permitte...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.has_change_permission
ModelAdmin.has_delete_permission(request, obj=None) Should return True if deleting obj is permitted, False otherwise. If obj is None, should return True or False to indicate whether deleting objects of this type is permitted in general (e.g., False will be interpreted as meaning that the current user is not permitted...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.has_delete_permission
ModelAdmin.has_module_permission(request) Should return True if displaying the module on the admin index page and accessing the module’s index page is permitted, False otherwise. Uses User.has_module_perms() by default. Overriding it does not restrict access to the view, add, change, or delete views, has_view_permiss...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.has_module_permission
ModelAdmin.has_view_permission(request, obj=None) Should return True if viewing obj is permitted, False otherwise. If obj is None, should return True or False to indicate whether viewing of objects of this type is permitted in general (e.g., False will be interpreted as meaning that the current user is not permitted ...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.has_view_permission
ModelAdmin.history_view(request, object_id, extra_context=None) Django view for the page that shows the modification history for a given model instance.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.history_view
ModelAdmin.inlines See InlineModelAdmin objects below as well as ModelAdmin.get_formsets_with_inlines().
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.inlines
ModelAdmin.list_display Set list_display to control which fields are displayed on the change list page of the admin. Example: list_display = ('first_name', 'last_name') If you don’t set list_display, the admin site will display a single column that displays the __str__() representation of each object. There are four...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.list_display
ModelAdmin.list_display_links Use list_display_links to control if and which fields in list_display should be linked to the “change” page for an object. By default, the change list page will link the first column – the first field specified in list_display – to the change page for each item. But list_display_links le...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.list_display_links
ModelAdmin.list_editable Set list_editable to a list of field names on the model which will allow editing on the change list page. That is, fields listed in list_editable will be displayed as form widgets on the change list page, allowing users to edit and save multiple rows at once. Note list_editable interacts wit...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.list_editable
ModelAdmin.list_filter Set list_filter to activate filters in the right sidebar of the change list page of the admin, as illustrated in the following screenshot: list_filter should be a list or tuple of elements, where each element should be of one of the following types: a field name, where the specified field sh...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.list_filter
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.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.list_max_show_all
ModelAdmin.list_per_page Set list_per_page to control how many items appear on each paginated admin change list page. By default, this is set to 100.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.list_per_page
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() ...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.list_select_related
ModelAdmin.lookup_allowed(lookup, value) The objects in the changelist page can be filtered with lookups from the URL’s query string. This is how list_filter works, for example. The lookups are similar to what’s used in QuerySet.filter() (e.g. user__email=user@example.com). Since the lookups in the query string can b...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.lookup_allowed
ModelAdmin.message_user(request, message, level=messages.INFO, extra_tags='', fail_silently=False) 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.mess...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.message_user
ModelAdmin.object_history_template Path to a custom template, used by history_view().
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.object_history_template
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 e...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.ordering
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().
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.paginator
ModelAdmin.popup_response_template Path to a custom template, used by response_add(), response_change(), and response_delete().
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.popup_response_template
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 m...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.prepopulated_fields
ModelAdmin.preserve_filters By default, applied filters are preserved on the list view after creating, editing, or deleting an object. You can have filters cleared by setting this attribute to False.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.preserve_filters
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)...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.radio_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 ...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.raw_id_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.fie...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.readonly_fields
ModelAdmin.response_add(request, obj, post_url_continue=None) 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...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.response_add
ModelAdmin.response_change(request, obj) 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.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.response_change
ModelAdmin.response_delete(request, obj_display, obj_id) 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 obje...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.response_delete
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 ne...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.save_as
ModelAdmin.save_as_continue 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.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.save_as_continue
ModelAdmin.save_formset(request, form, formset, change) 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....
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.save_formset
ModelAdmin.save_model(request, obj, form, change) 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. Overriding this method allows doing pre- or post-save operations. Call super().save_model() to save the ob...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.save_model
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.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.save_on_top
ModelAdmin.save_related(request, form, formsets, change) 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 p...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.save_related
ModelAdmin.search_fields Set search_fields to enable a search box on the admin change list page. This should be set to a list of field names that will be searched whenever somebody submits a search query in that text box. These fields should be some kind of text field, such as CharField or TextField. You can also per...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.search_fields
ModelAdmin.search_help_text New in Django 4.0. Set search_help_text to specify a descriptive text for the search box which will be displayed below it.
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.search_help_text
ModelAdmin.show_full_result_count Set show_full_result_count to control whether the full count of objects should be displayed on a filtered admin page (e.g. 99 results (103 total)). If this option is set to False, a text like 99 results (Show all) is displayed instead. The default of show_full_result_count=True gener...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.show_full_result_count
ModelAdmin.sortable_by By default, the change list page allows sorting by all model fields (and callables that use the ordering argument to the display() decorator or have the admin_order_field attribute) specified in list_display. If you want to disable sorting for some columns, set sortable_by to a collection (e.g....
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.sortable_by
ModelAdmin.view_on_site Set view_on_site to control whether or not to display the “View on site” link. This link should bring you to a URL where you can display the saved object. This value can be either a boolean flag or a callable. If True (the default), the object’s get_absolute_url() method will be used to genera...
django.ref.contrib.admin.index#django.contrib.admin.ModelAdmin.view_on_site
class models.LogEntry The LogEntry class tracks additions, changes, and deletions of objects done through the admin interface.
django.ref.contrib.admin.index#django.contrib.admin.models.LogEntry
LogEntry.action_flag The type of action logged: ADDITION, CHANGE, DELETION. For example, to get a list of all additions done through the admin: from django.contrib.admin.models import ADDITION, LogEntry LogEntry.objects.filter(action_flag=ADDITION)
django.ref.contrib.admin.index#django.contrib.admin.models.LogEntry.action_flag
LogEntry.action_time The date and time of the action.
django.ref.contrib.admin.index#django.contrib.admin.models.LogEntry.action_time
LogEntry.change_message The detailed description of the modification. In the case of an edit, for example, the message contains a list of the edited fields. The Django admin site formats this content as a JSON structure, so that get_change_message() can recompose a message translated in the current user language. Cus...
django.ref.contrib.admin.index#django.contrib.admin.models.LogEntry.change_message
LogEntry.content_type The ContentType of the modified object.
django.ref.contrib.admin.index#django.contrib.admin.models.LogEntry.content_type
LogEntry.get_change_message() Formats and translates change_message into the current user language. Messages created before Django 1.10 will always be displayed in the language in which they were logged.
django.ref.contrib.admin.index#django.contrib.admin.models.LogEntry.get_change_message
LogEntry.get_edited_object() A shortcut that returns the referenced object.
django.ref.contrib.admin.index#django.contrib.admin.models.LogEntry.get_edited_object
LogEntry.object_id The textual representation of the modified object’s primary key.
django.ref.contrib.admin.index#django.contrib.admin.models.LogEntry.object_id
LogEntry.object_repr The object`s repr() after the modification.
django.ref.contrib.admin.index#django.contrib.admin.models.LogEntry.object_repr
LogEntry.user The user (an AUTH_USER_MODEL instance) who performed the action.
django.ref.contrib.admin.index#django.contrib.admin.models.LogEntry.user
register(*models, site=django.contrib.admin.sites.site) There is also a decorator for registering your ModelAdmin classes: from django.contrib import admin from .models import Author @admin.register(Author) class AuthorAdmin(admin.ModelAdmin): pass It’s given one or more model classes to register with the Model...
django.ref.contrib.admin.index#django.contrib.admin.register
class StackedInline The admin interface has the ability to edit models on the same page as a parent model. These are called inlines. Suppose you have these two models: from django.db import models class Author(models.Model): name = models.CharField(max_length=100) class Book(models.Model): author = models.For...
django.ref.contrib.admin.index#django.contrib.admin.StackedInline
class TabularInline
django.ref.contrib.admin.index#django.contrib.admin.TabularInline
staff_member_required(redirect_field_name='next', login_url='admin:login') This decorator is used on the admin views that require authorization. A view decorated with this function will have the following behavior: If the user is logged in, is a staff member (User.is_staff=True), and is active (User.is_active=True),...
django.ref.contrib.admin.index#django.contrib.admin.views.decorators.staff_member_required
Aggregation The topic guide on Django’s database-abstraction API described the way that you can use Django queries that create, retrieve, update and delete individual objects. However, sometimes you will need to retrieve values that are derived by summarizing or aggregating a collection of objects. This topic guide des...
django.topics.db.aggregation
Applications Django contains a registry of installed applications that stores configuration and provides introspection. It also maintains a list of available models. This registry is called apps and it’s available in django.apps: >>> from django.apps import apps >>> apps.get_app_config('admin').verbose_name 'Administra...
django.ref.applications
class AppConfig Application configuration objects store metadata for an application. Some attributes can be configured in AppConfig subclasses. Others are set by Django and read-only.
django.ref.applications#django.apps.AppConfig
AppConfig.default New in Django 3.2. Set this attribute to False to prevent Django from selecting a configuration class automatically. This is useful when apps.py defines only one AppConfig subclass but you don’t want Django to use it by default. Set this attribute to True to tell Django to select a configuration c...
django.ref.applications#django.apps.AppConfig.default
AppConfig.default_auto_field New in Django 3.2. The implicit primary key type to add to models within this app. You can use this to keep AutoField as the primary key type for third party applications. By default, this is the value of DEFAULT_AUTO_FIELD.
django.ref.applications#django.apps.AppConfig.default_auto_field
AppConfig.get_model(model_name, require_ready=True) Returns the Model with the given model_name. model_name is case-insensitive. Raises LookupError if no such model exists in this application. Requires the app registry to be fully populated unless the require_ready argument is set to False. require_ready behaves exac...
django.ref.applications#django.apps.AppConfig.get_model
AppConfig.get_models() Returns an iterable of Model classes for this application. Requires the app registry to be fully populated.
django.ref.applications#django.apps.AppConfig.get_models
AppConfig.label Short name for the application, e.g. 'admin' This attribute allows relabeling an application when two applications have conflicting labels. It defaults to the last component of name. It should be a valid Python identifier. It must be unique across a Django project.
django.ref.applications#django.apps.AppConfig.label
AppConfig.models_module Module containing the models, e.g. <module 'django.contrib.admin.models' from 'django/contrib/admin/models.py'>. It may be None if the application doesn’t contain a models module. Note that the database related signals such as pre_migrate and post_migrate are only emitted for applications that...
django.ref.applications#django.apps.AppConfig.models_module
AppConfig.module Root module for the application, e.g. <module 'django.contrib.admin' from 'django/contrib/admin/__init__.py'>.
django.ref.applications#django.apps.AppConfig.module
AppConfig.name Full Python path to the application, e.g. 'django.contrib.admin'. This attribute defines which application the configuration applies to. It must be set in all AppConfig subclasses. It must be unique across a Django project.
django.ref.applications#django.apps.AppConfig.name
AppConfig.path Filesystem path to the application directory, e.g. '/usr/lib/pythonX.Y/dist-packages/django/contrib/admin'. In most cases, Django can automatically detect and set this, but you can also provide an explicit override as a class attribute on your AppConfig subclass. In a few situations this is required; f...
django.ref.applications#django.apps.AppConfig.path
AppConfig.ready() Subclasses can override this method to perform initialization tasks such as registering signals. It is called as soon as the registry is fully populated. Although you can’t import models at the module-level where AppConfig classes are defined, you can import them in ready(), using either an import s...
django.ref.applications#django.apps.AppConfig.ready
AppConfig.verbose_name Human-readable name for the application, e.g. “Administration”. This attribute defaults to label.title().
django.ref.applications#django.apps.AppConfig.verbose_name
apps The application registry provides the following public API. Methods that aren’t listed below are considered private and may change without notice.
django.ref.applications#django.apps.apps
apps.get_app_config(app_label) Returns an AppConfig for the application with the given app_label. Raises LookupError if no such application exists.
django.ref.applications#django.apps.apps.get_app_config
apps.get_app_configs() Returns an iterable of AppConfig instances.
django.ref.applications#django.apps.apps.get_app_configs
apps.get_model(app_label, model_name, require_ready=True) Returns the Model with the given app_label and model_name. As a shortcut, this method also accepts a single argument in the form app_label.model_name. model_name is case-insensitive. Raises LookupError if no such application or model exists. Raises ValueError ...
django.ref.applications#django.apps.apps.get_model
apps.is_installed(app_name) Checks whether an application with the given name exists in the registry. app_name is the full name of the app, e.g. 'django.contrib.admin'.
django.ref.applications#django.apps.apps.is_installed
apps.ready Boolean attribute that is set to True after the registry is fully populated and all AppConfig.ready() methods are called.
django.ref.applications#django.apps.apps.ready
authenticate(request=None, **credentials) Use authenticate() to verify a set of credentials. It takes credentials as keyword arguments, username and password for the default case, checks them against each authentication backend, and returns a User object if the credentials are valid for a backend. If the credentials ...
django.topics.auth.default#django.contrib.auth.authenticate
class AllowAllUsersModelBackend Same as ModelBackend except that it doesn’t reject inactive users because user_can_authenticate() always returns True. When using this backend, you’ll likely want to customize the AuthenticationForm used by the LoginView by overriding the confirm_login_allowed() method as it rejects in...
django.ref.contrib.auth#django.contrib.auth.backends.AllowAllUsersModelBackend
class AllowAllUsersRemoteUserBackend Same as RemoteUserBackend except that it doesn’t reject inactive users because user_can_authenticate always returns True.
django.ref.contrib.auth#django.contrib.auth.backends.AllowAllUsersRemoteUserBackend
class BaseBackend A base class that provides default implementations for all required methods. By default, it will reject any user and provide no permissions. get_user_permissions(user_obj, obj=None) Returns an empty set. get_group_permissions(user_obj, obj=None) Returns an empty set. get_all_permission...
django.ref.contrib.auth#django.contrib.auth.backends.BaseBackend
get_all_permissions(user_obj, obj=None) Uses get_user_permissions() and get_group_permissions() to get the set of permission strings the user_obj has.
django.ref.contrib.auth#django.contrib.auth.backends.BaseBackend.get_all_permissions
get_group_permissions(user_obj, obj=None) Returns an empty set.
django.ref.contrib.auth#django.contrib.auth.backends.BaseBackend.get_group_permissions
get_user_permissions(user_obj, obj=None) Returns an empty set.
django.ref.contrib.auth#django.contrib.auth.backends.BaseBackend.get_user_permissions
has_perm(user_obj, perm, obj=None) Uses get_all_permissions() to check if user_obj has the permission string perm.
django.ref.contrib.auth#django.contrib.auth.backends.BaseBackend.has_perm