mirror of https://github.com/django/django.git
Fixed #26997 -- Fixed checks crash with empty Meta.default_permissions.
This commit is contained in:
parent
f4b1f972dc
commit
4e64e3bb6e
|
@ -111,7 +111,10 @@ def check_models_permissions(app_configs=None, **kwargs):
|
|||
opts = model._meta
|
||||
builtin_permissions = dict(_get_builtin_permissions(opts))
|
||||
# Check builtin permission name length.
|
||||
max_builtin_permission_name_length = max(len(name) for name in builtin_permissions.values())
|
||||
max_builtin_permission_name_length = (
|
||||
max(len(name) for name in builtin_permissions.values())
|
||||
if builtin_permissions else 0
|
||||
)
|
||||
if max_builtin_permission_name_length > permission_name_max_length:
|
||||
verbose_name_max_length = (
|
||||
permission_name_max_length - (max_builtin_permission_name_length - len(opts.verbose_name_raw))
|
||||
|
|
|
@ -17,3 +17,6 @@ Bugfixes
|
|||
|
||||
* Removed the broken ``BaseCommand.usage()`` method which was for
|
||||
``optparse`` support (:ticket:`27000`).
|
||||
|
||||
* Fixed a checks framework crash with an empty ``Meta.default_permissions``
|
||||
(:ticket:`26997`).
|
||||
|
|
|
@ -195,3 +195,10 @@ class ModelsPermissionsChecksTests(SimpleTestCase):
|
|||
id='auth.E008',
|
||||
),
|
||||
])
|
||||
|
||||
def test_empty_default_permissions(self):
|
||||
class Checked(models.Model):
|
||||
class Meta:
|
||||
default_permissions = ()
|
||||
|
||||
self.assertEqual(checks.run_checks(self.apps.get_app_configs()), [])
|
||||
|
|
Loading…
Reference in New Issue