diff --git a/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py b/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py new file mode 100644 index 0000000000..8e82223237 --- /dev/null +++ b/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py @@ -0,0 +1,19 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.db import models, migrations + + +class Migration(migrations.Migration): + + dependencies = [ + ('auth', '0001_initial'), + ] + + operations = [ + migrations.AlterField( + model_name='permission', + name='name', + field=models.CharField(max_length=255, verbose_name='name'), + ), + ] diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index 14f0a5ecd8..9c6f7247bf 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -61,7 +61,7 @@ class Permission(models.Model): Three basic permissions -- add, change and delete -- are automatically created for each Django model. """ - name = models.CharField(_('name'), max_length=50) + name = models.CharField(_('name'), max_length=255) content_type = models.ForeignKey(ContentType) codename = models.CharField(_('codename'), max_length=100) objects = PermissionManager() diff --git a/django/contrib/auth/tests/test_management.py b/django/contrib/auth/tests/test_management.py index a800b7379a..fc016135b2 100644 --- a/django/contrib/auth/tests/test_management.py +++ b/django/contrib/auth/tests/test_management.py @@ -503,8 +503,8 @@ class PermissionTestCase(TestCase): permission_content_type = ContentType.objects.get_by_natural_key('auth', 'permission') models.Permission.objects.filter(content_type=permission_content_type).delete() - models.Permission._meta.verbose_name = "some ridiculously long verbose name that is out of control" + models.Permission._meta.verbose_name = "some ridiculously long verbose name that is out of control" * 5 six.assertRaisesRegex(self, exceptions.ValidationError, - "The verbose_name of permission is longer than 39 characters", + "The verbose_name of permission is longer than 244 characters", create_permissions, auth_app_config, verbosity=0) diff --git a/docs/releases/1.8.txt b/docs/releases/1.8.txt index 96bcc55051..7534a16e3d 100644 --- a/docs/releases/1.8.txt +++ b/docs/releases/1.8.txt @@ -46,6 +46,9 @@ Minor features * :class:`~django.contrib.auth.forms.PasswordResetForm` now has a method :meth:`~django.contrib.auth.forms.PasswordResetForm.send_email` that can be overridden to customize the mail to be sent. +* The ``max_length`` of :attr:`Permission.name + ` has been increased from 50 to + 255 characters. Please run the database migration. :mod:`django.contrib.formtools` ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^