#23926: Misleading error message provided when custom permission names are too 
long
------------------------------+--------------------
     Reporter:  Greatlemer    |      Owner:  nobody
         Type:  Bug           |     Status:  new
    Component:  contrib.auth  |    Version:  1.7
     Severity:  Normal        |   Keywords:
 Triage Stage:  Unreviewed    |  Has patch:  0
Easy pickings:  0             |      UI/UX:  0
------------------------------+--------------------
 Whilst adding a new custom permission to a model, I accidentally created
 one that was too long and instead of being informed the problem was an
 overly long name field, the validation error raised complained about the
 verbose name of my model being too long.

 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.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/053.7d507d5e1f0d6dd22f76f3a959c51ea8%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to