class documentation

class AdminSite: (source)

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 __init__ Undocumented
Method __repr__ Undocumented
Method add_action Register an action to be available globally.
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 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 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 has_permission Return True if the given HttpRequest has permission to view *at least one* page in the admin site.
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.
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
Instance Variable name Undocumented
Property actions Get all the enabled actions as an iterable of (name, func).
Property urls Undocumented
Method _build_app_dict Build the app dictionary. The optional `label` parameter filters models of a specific app.
Instance Variable _actions Undocumented
Instance Variable _global_actions Undocumented
Instance Variable _registry Undocumented
def __init__(self, name='admin'): (source)

Undocumented

def __repr__(self): (source)

Undocumented

def add_action(self, action, name=None): (source)

Register an action to be available globally.

def admin_view(self, view, cacheable=False): (source)

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): (source)

Undocumented

def autocomplete_view(self, request): (source)

Undocumented

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

Undocumented

def check(self, app_configs): (source)

Run the system checks on all ModelAdmins, except if they aren't customized at all.

def disable_action(self, name): (source)

Disable a globally-registered action. Raise KeyError for invalid names.

def each_context(self, request): (source)

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 get_action(self, name): (source)

Explicitly get a registered global action whether it's enabled or not. Raise KeyError for invalid names.

def get_app_list(self, request, app_label=None): (source)

Return a sorted list of all the installed apps that have been registered in this site.

def get_urls(self): (source)

Undocumented

def has_permission(self, request): (source)

Return True if the given HttpRequest has permission to view *at least one* page in the admin site.

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

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): (source)

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): (source)

Check if a model class is registered with this `AdminSite`.

@method_decorator(never_cache)
def login(self, request, extra_context=None): (source)

Display the login form for the given HttpRequest.

def logout(self, request, extra_context=None): (source)

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): (source)

Handle the "change password" task -- both form display and validation.

def password_change_done(self, request, extra_context=None): (source)

Display the "success" page after a password change.

def register(self, model_or_iterable, admin_class=None, **options): (source)

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): (source)

Unregister the given model(s). If a model isn't already registered, raise NotRegistered.

app_index_template = (source)

Undocumented

empty_value_display: str = (source)

Undocumented

enable_nav_sidebar: bool = (source)

Undocumented

final_catch_all_view: bool = (source)

Undocumented

index_template = (source)

Undocumented

index_title = (source)

Undocumented

login_form = (source)

Undocumented

login_template = (source)

Undocumented

logout_template = (source)

Undocumented

password_change_done_template = (source)

Undocumented

password_change_template = (source)

Undocumented

site_header = (source)

Undocumented

site_title = (source)

Undocumented

site_url: str = (source)

Undocumented

Undocumented

Get all the enabled actions as an iterable of (name, func).

Undocumented

def _build_app_dict(self, request, label=None): (source)

Build the app dictionary. The optional `label` parameter filters models of a specific app.

_actions = (source)

Undocumented

_global_actions = (source)

Undocumented

_registry: dict = (source)

Undocumented