class documentation

class AdminSite:

View In Hierarchy

An AdminSite object encapsulates an instance of the Django admin application, ready to be hooked in to your URLconf. Models are registered with the AdminSite using the register() method, and the get_urls() method can then be used to access Django view functions that present a full admin interface for the collection of registered models.
Method add​_action Register an action to be available globally.
Method disable​_action Disable a globally-registered action. Raise KeyError for invalid names.
Method each​_context Return a dictionary of variables to put in the template context for every page in the admin site.
Method has​_permission Return True if the given HttpRequest has permission to view at least one page in the admin site.
Method register Register the given model(s) with the given admin class.
Method unregister Unregister the given model(s).
Class Variable app​_index​_template Undocumented
Class Variable empty​_value​_display Undocumented
Class Variable enable​_nav​_sidebar Undocumented
Class Variable final​_catch​_all​_view Undocumented
Class Variable index​_template Undocumented
Class Variable index​_title Undocumented
Class Variable login​_form Undocumented
Class Variable login​_template Undocumented
Class Variable logout​_template Undocumented
Class Variable password​_change​_done​_template Undocumented
Class Variable password​_change​_template Undocumented
Class Variable site​_header Undocumented
Class Variable site​_title Undocumented
Class Variable site​_url Undocumented
Method __init__ Undocumented
Method __repr__ Undocumented
Method ​_build​_app​_dict Build the app dictionary. The optional label parameter filters models of a specific app.
Method admin​_view Decorator to create an admin view attached to this AdminSite. This wraps the view and provides permission checking by calling self.has_permission.
Method app​_index Undocumented
Method autocomplete​_view Undocumented
Method catch​_all​_view Undocumented
Method check Run the system checks on all ModelAdmins, except if they aren't customized at all.
Method get​_action Explicitly get a registered global action whether it's enabled or not. Raise KeyError for invalid names.
Method get​_app​_list Return a sorted list of all the installed apps that have been registered in this site.
Method get​_urls Undocumented
Method i18n​_javascript Display the i18n JavaScript that the Django admin requires.
Method index Display the main admin index page, which lists all of the installed apps that have been registered in this site.
Method is​_registered Check if a model class is registered with this AdminSite.
Method login Display the login form for the given HttpRequest.
Method logout Log out the user for the given HttpRequest.
Method password​_change Handle the "change password" task -- both form display and validation.
Method password​_change​_done Display the "success" page after a password change.
Instance Variable ​_actions Undocumented
Instance Variable ​_global​_actions Undocumented
Instance Variable ​_registry Undocumented
Instance Variable name Undocumented
Property actions Get all the enabled actions as an iterable of (name, func).
Property urls Undocumented
def add_action(self, action, name=None):
Register an action to be available globally.
def disable_action(self, name):
Disable a globally-registered action. Raise KeyError for invalid names.
def each_context(self, request):

Return a dictionary of variables to put in the template context for every page in the admin site.

For sites running on a subpath, use the SCRIPT_NAME value if site_url hasn't been customized.

def has_permission(self, request):
Return True if the given HttpRequest has permission to view at least one page in the admin site.
def register(self, model_or_iterable, admin_class=None, **options):

Register the given model(s) with the given admin class.

The model(s) should be Model classes, not instances.

If an admin class isn't given, use ModelAdmin (the default admin options). If keyword arguments are given -- e.g., list_display -- apply them as options to the admin class.

If a model is already registered, raise AlreadyRegistered.

If a model is abstract, raise ImproperlyConfigured.

def unregister(self, model_or_iterable):

Unregister the given model(s).

If a model isn't already registered, raise NotRegistered.

app_index_template =

Undocumented

empty_value_display: str =

Undocumented

enable_nav_sidebar: bool =

Undocumented

final_catch_all_view: bool =

Undocumented

index_template =

Undocumented

index_title =

Undocumented

login_form =

Undocumented

login_template =

Undocumented

logout_template =

Undocumented

password_change_done_template =

Undocumented

password_change_template =

Undocumented

site_header =

Undocumented

site_title =

Undocumented

site_url: str =

Undocumented

def __init__(self, name='admin'):

Undocumented

def __repr__(self):

Undocumented

def _build_app_dict(self, request, label=None):
Build the app dictionary. The optional label parameter filters models of a specific app.
def admin_view(self, view, cacheable=False):

Decorator to create an admin view attached to this AdminSite. This wraps the view and provides permission checking by calling self.has_permission.

You'll want to use this from within AdminSite.get_urls():

class MyAdminSite(AdminSite):

def get_urls(self):

from django.urls import path

urls = super().get_urls() urls += [

path('my_view/', self.admin_view(some_view))

] return urls

By default, admin_views are marked non-cacheable using the never_cache decorator. If the view can be safely cached, set cacheable=True.

def app_index(self, request, app_label, extra_context=None):

Undocumented

def autocomplete_view(self, request):

Undocumented

@no_append_slash
def catch_all_view(self, request, url):

Undocumented

def check(self, app_configs):
Run the system checks on all ModelAdmins, except if they aren't customized at all.
def get_action(self, name):
Explicitly get a registered global action whether it's enabled or not. Raise KeyError for invalid names.
def get_app_list(self, request):
Return a sorted list of all the installed apps that have been registered in this site.
def get_urls(self):

Undocumented

def i18n_javascript(self, request, extra_context=None):

Display the i18n JavaScript that the Django admin requires.

extra_context is unused but present for consistency with the other admin views.

def index(self, request, extra_context=None):
Display the main admin index page, which lists all of the installed apps that have been registered in this site.
def is_registered(self, model):
Check if a model class is registered with this AdminSite.
@method_decorator(never_cache)
def login(self, request, extra_context=None):
Display the login form for the given HttpRequest.
def logout(self, request, extra_context=None):

Log out the user for the given HttpRequest.

This should not assume the user is already logged in.

def password_change(self, request, extra_context=None):
Handle the "change password" task -- both form display and validation.
def password_change_done(self, request, extra_context=None):
Display the "success" page after a password change.
_actions =

Undocumented

_global_actions =

Undocumented

_registry: dict =

Undocumented

name =

Undocumented

@property
actions =
Get all the enabled actions as an iterable of (name, func).
@property
urls =

Undocumented