diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py index ba754bd873..e088bc9142 100644 --- a/django/contrib/admin/checks.py +++ b/django/contrib/admin/checks.py @@ -607,8 +607,9 @@ class BaseModelAdminChecks: except FieldDoesNotExist: return [ checks.Error( - "The value of '%s' is not a callable, an attribute of '%s', or an attribute of '%s.%s'." % ( - label, obj.__class__.__name__, obj.model._meta.app_label, obj.model._meta.object_name + "The value of '%s' is not a callable, an attribute of " + "'%s', or an attribute of '%s'." % ( + label, obj.__class__.__name__, obj.model._meta.label, ), obj=obj.__class__, id='admin.E035', @@ -731,9 +732,9 @@ class ModelAdminChecks(BaseModelAdminChecks): checks.Error( "The value of '%s' refers to '%s', which is not a " "callable, an attribute of '%s', or an attribute or " - "method on '%s.%s'." % ( + "method on '%s'." % ( label, item, obj.__class__.__name__, - obj.model._meta.app_label, obj.model._meta.object_name, + obj.model._meta.label, ), obj=obj.__class__, id='admin.E108', @@ -1035,8 +1036,8 @@ class InlineModelAdminChecks(BaseModelAdminChecks): return [ checks.Error( "Cannot exclude the field '%s', because it is the foreign key " - "to the parent model '%s.%s'." % ( - fk.name, parent_model._meta.app_label, parent_model._meta.object_name + "to the parent model '%s'." % ( + fk.name, parent_model._meta.label, ), obj=obj.__class__, id='admin.E201', @@ -1113,9 +1114,8 @@ def must_inherit_from(parent, option, obj, id): def refer_to_missing_field(field, option, obj, id): return [ checks.Error( - "The value of '%s' refers to '%s', which is not an attribute of '%s.%s'." % ( - option, field, obj.model._meta.app_label, obj.model._meta.object_name - ), + "The value of '%s' refers to '%s', which is not an attribute of " + "'%s'." % (option, field, obj.model._meta.label), obj=obj.__class__, id=id, ), diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py index c5a2f0e822..bd566cde40 100644 --- a/django/contrib/admindocs/views.py +++ b/django/contrib/admindocs/views.py @@ -307,7 +307,7 @@ class ModelDetailView(BaseAdminDocsView): }) return super().get_context_data(**{ **kwargs, - 'name': '%s.%s' % (opts.app_label, opts.object_name), + 'name': opts.label, 'summary': title, 'description': body, 'fields': fields, diff --git a/django/contrib/auth/checks.py b/django/contrib/auth/checks.py index b77cfe2645..163199ce54 100644 --- a/django/contrib/auth/checks.py +++ b/django/contrib/auth/checks.py @@ -119,9 +119,10 @@ def check_models_permissions(app_configs=None, **kwargs): ) errors.append( checks.Error( - "The verbose_name of model '%s.%s' must be at most %d characters " - "for its builtin permission names to be at most %d characters." % ( - opts.app_label, opts.object_name, verbose_name_max_length, permission_name_max_length + "The verbose_name of model '%s' must be at most %d " + "characters for its builtin permission names to be at " + "most %d characters." % ( + opts.label, verbose_name_max_length, permission_name_max_length ), obj=model, id='auth.E007', @@ -138,11 +139,10 @@ def check_models_permissions(app_configs=None, **kwargs): ) errors.append( checks.Error( - "The name of model '%s.%s' must be at most %d characters " + "The name of model '%s' must be at most %d characters " "for its builtin permission codenames to be at most %d " "characters." % ( - opts.app_label, - opts.object_name, + opts.label, model_name_max_length, permission_codename_max_length, ), @@ -156,8 +156,9 @@ def check_models_permissions(app_configs=None, **kwargs): if len(name) > permission_name_max_length: errors.append( checks.Error( - "The permission named '%s' of model '%s.%s' is longer than %d characters." % ( - name, opts.app_label, opts.object_name, permission_name_max_length + "The permission named '%s' of model '%s' is longer " + "than %d characters." % ( + name, opts.label, permission_name_max_length, ), obj=model, id='auth.E008', @@ -167,11 +168,10 @@ def check_models_permissions(app_configs=None, **kwargs): if len(codename) > permission_codename_max_length: errors.append( checks.Error( - "The permission codenamed '%s' of model '%s.%s' is " + "The permission codenamed '%s' of model '%s' is " "longer than %d characters." % ( codename, - opts.app_label, - opts.object_name, + opts.label, permission_codename_max_length, ), obj=model, @@ -183,9 +183,7 @@ def check_models_permissions(app_configs=None, **kwargs): errors.append( checks.Error( "The permission codenamed '%s' clashes with a builtin permission " - "for model '%s.%s'." % ( - codename, opts.app_label, opts.object_name - ), + "for model '%s'." % (codename, opts.label), obj=model, id='auth.E005', ) @@ -193,9 +191,8 @@ def check_models_permissions(app_configs=None, **kwargs): elif codename in codenames: errors.append( checks.Error( - "The permission codenamed '%s' is duplicated for model '%s.%s'." % ( - codename, opts.app_label, opts.object_name - ), + "The permission codenamed '%s' is duplicated for " + "model '%s'." % (codename, opts.label), obj=model, id='auth.E006', ) diff --git a/django/core/serializers/__init__.py b/django/core/serializers/__init__.py index 4b0ae078e2..d0e504ade3 100644 --- a/django/core/serializers/__init__.py +++ b/django/core/serializers/__init__.py @@ -225,7 +225,7 @@ def sort_dependencies(app_list): raise RuntimeError( "Can't resolve dependencies for %s in serialized app list." % ', '.join( - '%s.%s' % (model._meta.app_label, model._meta.object_name) + model._meta.label for model, deps in sorted(skipped, key=lambda obj: obj[0].__name__) ) ) diff --git a/django/db/models/options.py b/django/db/models/options.py index 08c80bb6c8..5c527563d7 100644 --- a/django/db/models/options.py +++ b/django/db/models/options.py @@ -307,7 +307,7 @@ class Options: return '' % self.object_name def __str__(self): - return "%s.%s" % (self.app_label, self.model_name) + return self.label_lower def can_migrate(self, connection): """