This was observed in Django 1.7.1 under python 2.7.
I was able to reproduce it by putting the following code in the models.py
of an application listed in INSTALLED_APPS:
{{{
from django.db.models import Model
class Tmp(Model):
class Meta:
permissions = (
(
'can_do_something_long',
'A custom permission name with greater than 50 chars',
),
)
}}}
Then when I ran ./manage.py migrate I got the following error:
{{{
(env)blah> python ./manage.py migrate
Operations to perform:
Synchronize unmigrated apps: blah
Apply all migrations: admin, contenttypes, auth, sessions
Synchronizing apps without migrations:
Creating tables...
Creating table blah_tmp
Installing custom SQL...
Installing indexes...
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying sessions.0001_initial... OK
Traceback (most recent call last):
File "./manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/data/home/ar/tmp/perm_issue/env/lib/python2.7/site-
packages/django/core/management/__init__.py", line 385, in
execute_from_command_line
utility.execute()
File "/data/home/ar/tmp/perm_issue/env/lib/python2.7/site-
packages/django/core/management/__init__.py", line 377, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/data/home/ar/tmp/perm_issue/env/lib/python2.7/site-
packages/django/core/management/base.py", line 288, in run_from_argv
self.execute(*args, **options.__dict__)
File "/data/home/ar/tmp/perm_issue/env/lib/python2.7/site-
packages/django/core/management/base.py", line 338, in execute
output = self.handle(*args, **options)
File "/data/home/ar/tmp/perm_issue/env/lib/python2.7/site-
packages/django/core/management/commands/migrate.py", line 164, in handle
emit_post_migrate_signal(created_models, self.verbosity,
self.interactive, connection.alias)
File "/data/home/ar/tmp/perm_issue/env/lib/python2.7/site-
packages/django/core/management/sql.py", line 268, in
emit_post_migrate_signal
using=db)
File "/data/home/ar/tmp/perm_issue/env/lib/python2.7/site-
packages/django/dispatch/dispatcher.py", line 198, in send
response = receiver(signal=self, sender=sender, **named)
File "/data/home/ar/tmp/perm_issue/env/lib/python2.7/site-
packages/django/contrib/auth/management/__init__.py", line 111, in
create_permissions
verbose_name_max_length,
django.core.exceptions.ValidationError: [u'The verbose_name of tmp is
longer than 39 characters']
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/23926>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:1>
* cc: shaib (added)
Comment:
This is actually fixed by #8162 which was fixed (only on master) by
cf252dbea. I'm not sure if we should backport.
--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:2>
Comment (by timgraham):
The message is still misleading in that it references `verbose_name` even
for custom permissions.
--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:3>
Comment (by shaib):
I'd thought for a second that the fix for #8162 fixed that too, because
the test code included there uses permissions on permissions. I enjoy
ironic recursion like anyone else, but it might be clearer to change that.
--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:4>
* status: new => assigned
* owner: nobody => joeri
--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:5>
Comment (by joeri):
The error is technically correct but in some cases doesn't point people to
the most obvious cause. The cryptic database error mentioned in #18866
was replaced with the current message. It was an improvement but with
custom permissions, the error is still cryptic.
--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:6>
Comment (by joeri):
Added PR https://github.com/django/django/pull/4274
--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:7>
* has_patch: 0 => 1
* stage: Accepted => Ready for checkin
--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:8>
* status: assigned => closed
* resolution: => fixed
Comment:
In [changeset:"0ed20d5cc4bf94646ffd4e4fcbd963b9916039cd" 0ed20d5]:
{{{
#!CommitTicketReference repository=""
revision="0ed20d5cc4bf94646ffd4e4fcbd963b9916039cd"
Fixed #23926 -- Improved validation error for custom permissions that are
too long.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/23926#comment:9>