mirror of
https://github.com/django/django.git
synced 2025-10-25 22:56:12 +00:00
Refs #24121 -- Added __repr__() to AdminSite, DefaultAdminSite, and ModelAdmin.
Thanks tlebrize for the initial patch.
This commit is contained in:
committed by
Mariusz Felisiak
parent
fa35c8bdbc
commit
e4da365436
@@ -594,6 +594,12 @@ class ModelAdmin(BaseModelAdmin):
|
||||
def __str__(self):
|
||||
return "%s.%s" % (self.model._meta.app_label, self.__class__.__name__)
|
||||
|
||||
def __repr__(self):
|
||||
return (
|
||||
f'<{self.__class__.__qualname__}: model={self.model.__qualname__} '
|
||||
f'site={self.admin_site!r}>'
|
||||
)
|
||||
|
||||
def get_inline_instances(self, request, obj=None):
|
||||
inline_instances = []
|
||||
for inline_class in self.get_inlines(request, obj):
|
||||
|
||||
@@ -77,6 +77,9 @@ class AdminSite:
|
||||
self._global_actions = self._actions.copy()
|
||||
all_sites.add(self)
|
||||
|
||||
def __repr__(self):
|
||||
return f'{self.__class__.__name__}(name={self.name!r})'
|
||||
|
||||
def check(self, app_configs):
|
||||
"""
|
||||
Run the system checks on all ModelAdmins, except if they aren't
|
||||
@@ -561,6 +564,9 @@ class DefaultAdminSite(LazyObject):
|
||||
AdminSiteClass = import_string(apps.get_app_config('admin').default_site)
|
||||
self._wrapped = AdminSiteClass()
|
||||
|
||||
def __repr__(self):
|
||||
return repr(self._wrapped)
|
||||
|
||||
|
||||
# This global object represents the default admin site, for the common case.
|
||||
# You can provide your own AdminSite using the (Simple)AdminConfig.default_site
|
||||
|
||||
Reference in New Issue
Block a user