[Django] #18866: model Meta verbose_name too long error message not obvious

26 views
Skip to first unread message

Django

unread,
Aug 28, 2012, 1:49:14 AM8/28/12
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
-------------------------------+--------------------
Reporter: elena | Owner: nobody
Type: Uncategorized | Status: new
Component: Uncategorized | Version: 1.4
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------+--------------------
Running:

{{{$ python manage.py syncdb}}}

The following error messages:

Postgres:
{{{
Creating tables ...
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Library/Python/2.7/site-
packages/django/core/management/__init__.py", line 443, in
execute_from_command_line
utility.execute()
File "/Library/Python/2.7/site-
packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Library/Python/2.7/site-packages/django/core/management/base.py",
line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Library/Python/2.7/site-packages/django/core/management/base.py",
line 232, in execute
output = self.handle(*args, **options)
File "/Library/Python/2.7/site-packages/django/core/management/base.py",
line 371, in handle
return self.handle_noargs(**options)
File "/Library/Python/2.7/site-
packages/django/core/management/commands/syncdb.py", line 110, in
handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
File "/Library/Python/2.7/site-packages/django/core/management/sql.py",
line 189, in emit_post_sync_signal
interactive=interactive, db=db)
File "/Library/Python/2.7/site-packages/django/dispatch/dispatcher.py",
line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "/Library/Python/2.7/site-
packages/django/contrib/auth/management/__init__.py", line 54, in
create_permissions
auth_app.Permission.objects.bulk_create(objs)
File "/Library/Python/2.7/site-packages/django/db/models/manager.py",
line 140, in bulk_create
return self.get_query_set().bulk_create(*args, **kwargs)
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line
416, in bulk_create
self.model._base_manager._insert(objs_without_pk, fields=[f for f in
fields if not isinstance(f, AutoField)], using=self.db)
File "/Library/Python/2.7/site-packages/django/db/models/manager.py",
line 203, in _insert
return insert_query(self.model, objs, fields, **kwargs)
File "/Library/Python/2.7/site-packages/django/db/models/query.py", line
1576, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/Library/Python/2.7/site-
packages/django/db/models/sql/compiler.py", line 910, in execute_sql
cursor.execute(sql, params)
File "/Library/Python/2.7/site-packages/django/db/backends/util.py",
line 40, in execute
return self.cursor.execute(sql, params)
File "/Library/Python/2.7/site-
packages/django/db/backends/postgresql_psycopg2/base.py", line 52, in
execute
return self.cursor.execute(query, args)
django.db.utils.DatabaseError: value too long for type character
varying(50)
}}}

MySQL:
{{{
Creating tables ...
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/django/core/management/__init__.py", line 443, in
execute_from_command_line
utility.execute()
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/django/core/management/__init__.py", line 382, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/django/core/management/base.py", line 196, in run_from_argv
self.execute(*args, **options.__dict__)
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/django/core/management/base.py", line 232, in execute
output = self.handle(*args, **options)
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/django/core/management/base.py", line 371, in handle
return self.handle_noargs(**options)
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/django/core/management/commands/syncdb.py", line 110, in
handle_noargs
emit_post_sync_signal(created_models, verbosity, interactive, db)
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/django/core/management/sql.py", line 189, in
emit_post_sync_signal
interactive=interactive, db=db)
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/django/dispatch/dispatcher.py", line 172, in send
response = receiver(signal=self, sender=sender, **named)
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/django/contrib/auth/management/__init__.py", line 54, in
create_permissions
auth_app.Permission.objects.bulk_create(objs)
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/django/db/models/manager.py", line 140, in bulk_create
return self.get_query_set().bulk_create(*args, **kwargs)
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/django/db/models/query.py", line 416, in bulk_create
self.model._base_manager._insert(objs_without_pk, fields=[f for f in
fields if not isinstance(f, AutoField)], using=self.db)
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/django/db/models/manager.py", line 203, in _insert
return insert_query(self.model, objs, fields, **kwargs)
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/django/db/models/query.py", line 1576, in insert_query
return query.get_compiler(using=using).execute_sql(return_id)
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/django/db/models/sql/compiler.py", line 910, in execute_sql
cursor.execute(sql, params)
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/django/db/backends/util.py", line 40, in execute
return self.cursor.execute(sql, params)
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/django/db/backends/mysql/base.py", line 114, in execute
return self.cursor.execute(query, args)
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/MySQLdb/cursors.py", line 176, in execute
if not self._defer_warnings: self._warning_check()
File "/Users/elena/.virtualenvs/wc/lib/python2.7/site-
packages/MySQLdb/cursors.py", line 92, in _warning_check
warn(w[-1], self.Warning, 3)
_mysql_exceptions.Warning: Data truncated for column 'name' at row 13
}}}

What is this error?

It is caused by {{{contenttypes.name}}}, see SO:
http://stackoverflow.com/questions/10855978/heroku-and-django-value-too-
long-for-type-character-varying50

Easily replicated:

{{{
class MyModel(models.Model):
class Meta:
verbose_name = "soem ridiculously long verbose name that is out of
control"
}}}

This is not serious. It's just not obvious.

--
Ticket URL: <https://code.djangoproject.com/ticket/18866>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
Sep 7, 2012, 6:34:50 AM9/7/12
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
-------------------------------------+-------------------------------------
Reporter: elena | Owner: nobody
Type: Uncategorized | Status: new
Component: Database layer | Version: 1.4
(models, ORM) | Resolution:
Severity: Normal | Triage Stage:
Keywords: | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by thejaswi_puthraya):

* needs_better_patch: => 0
* component: Uncategorized => Database layer (models, ORM)
* needs_tests: => 0
* needs_docs: => 0


--
Ticket URL: <https://code.djangoproject.com/ticket/18866#comment:1>

Django

unread,
Nov 16, 2012, 6:07:03 PM11/16/12
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
------------------------------+------------------------------------
Reporter: elena | Owner: nobody
Type: Bug | Status: new
Component: contrib.auth | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by aaugustin):

* component: Database layer (models, ORM) => contrib.auth
* type: Uncategorized => Bug
* stage: Unreviewed => Accepted


Comment:

Yes, I've hit that several times myself. It's annoying. syncdb crashes
because it tries to create a permission with a name that's longer than 50
characters.

Possible solutions:
- improve the error message
- display a warning and truncate the value
- increase the size of the field to 200 characters (insert usual rant
about lack of migrations in core here)

--
Ticket URL: <https://code.djangoproject.com/ticket/18866#comment:2>

Django

unread,
Nov 18, 2012, 4:05:25 PM11/18/12
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
------------------------------+------------------------------------
Reporter: elena | Owner: nobody

Type: Bug | Status: new
Component: contrib.auth | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by GabrielNar89):

This is a Windows* OS/file system issue.The cause is directory paths on
the drive is longer than 255 characters (including spaces).There's a lot
of additional softwares which can fix this problem like Long Path Tool.
http://PathTooDeep.com

--
Ticket URL: <https://code.djangoproject.com/ticket/18866#comment:3>

Django

unread,
Nov 18, 2012, 4:37:47 PM11/18/12
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
------------------------------+------------------------------------
Reporter: elena | Owner: nobody

Type: Bug | Status: new
Component: contrib.auth | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by aaugustin):

The backtrace clearly comes from OS X — see the `/Users/<username>` path —
and this isn't related to the filesystem.

--
Ticket URL: <https://code.djangoproject.com/ticket/18866#comment:4>

Django

unread,
May 18, 2013, 12:37:37 PM5/18/13
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
------------------------------+------------------------------------
Reporter: elena | Owner: nobody

Type: Bug | Status: new
Component: contrib.auth | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by djangsters):

I added a simple validation before bulk_creation and a hint to the
verbose_name
see: https://github.com/django/django/pull/1140

--
Ticket URL: <https://code.djangoproject.com/ticket/18866#comment:5>

Django

unread,
May 19, 2013, 5:57:47 AM5/19/13
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
------------------------------+------------------------------------
Reporter: elena | Owner: nobody

Type: Bug | Status: new
Component: contrib.auth | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by filias):

Wouldn't it be good to have a test for this?

--
Ticket URL: <https://code.djangoproject.com/ticket/18866#comment:6>

Django

unread,
May 19, 2013, 6:23:38 AM5/19/13
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
------------------------------+------------------------------------
Reporter: elena | Owner: nobody

Type: Bug | Status: new
Component: contrib.auth | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by filias):

* has_patch: 0 => 1
* needs_tests: 0 => 1


--
Ticket URL: <https://code.djangoproject.com/ticket/18866#comment:7>

Django

unread,
Jul 8, 2013, 6:06:20 AM7/8/13
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
------------------------------+------------------------------------
Reporter: elena | Owner: nobody

Type: Bug | Status: new
Component: contrib.auth | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by kerry@…):

* cc: kerry@… (added)


Comment:

This also applies with a very similar error if you create your own Model
permissions in Meta with a description over 50 Chars,

{{{
class Meta:
permissions = (
("view_desks", "Can view desks"),
("track_attendance", "Can track attended/no-show with this
unfeasibly long description of over 50 Chars"),
)

}}}

I've added this comment in case it's useful to someone else following the
same route as me when identifying the problem.

Would it make sense to fix under this ticket or shall I put in a new
ticket?

--
Ticket URL: <https://code.djangoproject.com/ticket/18866#comment:8>

Django

unread,
Sep 8, 2013, 11:19:20 AM9/8/13
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
------------------------------+------------------------------------
Reporter: elena | Owner: nobody

Type: Bug | Status: new
Component: contrib.auth | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by rasca):

Related to #18959 that tracks the verbose_name errors

--
Ticket URL: <https://code.djangoproject.com/ticket/18866#comment:9>

Django

unread,
Sep 23, 2013, 9:57:41 AM9/23/13
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
------------------------------+------------------------------------
Reporter: elena | Owner: nobody

Type: Bug | Status: new
Component: contrib.auth | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by toyg):

Ok, the problem is a bit more complex, and the abovementioned patch does
not fix it.

The problem is that verbose_name is used to generate the auth_permission
table; the "name" field in that table is set to varchar(50) (at least on
PostgreSQL), but this record actually includes sentences ("Can add
<verbose_name>", "Can delete <verbose_name>" and so on); so '''the actual
practical limit is 39 characters for verbose_name'''. This is a weird
number, common knowledge is that verbose_name can be up to 50 characters.

So the real fix is either to widen that field to 61 or more (50 + "Can
delete ", which is 11 characters), or document that the limit is 39 on
non-sqlite backends.

I have a test and a fix for the validator to spot values that are too
long, but there's no point in submitting a pull request if this point
isn't settled first.

--
Ticket URL: <https://code.djangoproject.com/ticket/18866#comment:10>

Django

unread,
Sep 23, 2013, 10:24:30 AM9/23/13
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
------------------------------+-------------------------------------
Reporter: elena | Owner: nobody
Type: Bug | Status: closed
Component: contrib.auth | Version: 1.4
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+-------------------------------------
Changes (by toyg):

* status: new => closed
* resolution: => duplicate


Comment:

Duplicate of #8548 and #8162

--
Ticket URL: <https://code.djangoproject.com/ticket/18866#comment:11>

Django

unread,
Sep 23, 2013, 10:26:29 AM9/23/13
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
------------------------------+------------------------------------
Reporter: elena | Owner: nobody
Type: Bug | Status: new

Component: contrib.auth | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by toyg):

* status: closed => new
* resolution: duplicate =>


--
Ticket URL: <https://code.djangoproject.com/ticket/18866#comment:12>

Django

unread,
Sep 23, 2013, 10:27:22 AM9/23/13
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
------------------------------+------------------------------------
Reporter: elena | Owner: toyg
Type: Bug | Status: assigned

Component: contrib.auth | Version: 1.4
Severity: Normal | Resolution:
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by toyg):

* owner: nobody => toyg
* status: new => assigned


Comment:

Ok, using this bug to track *validation* only - the actual limit will stay
at 39 as per #8162.

--
Ticket URL: <https://code.djangoproject.com/ticket/18866#comment:13>

Django

unread,
Oct 14, 2013, 9:21:06 AM10/14/13
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
------------------------------+------------------------------------
Reporter: elena | Owner: toyg
Type: Bug | Status: closed
Component: contrib.auth | Version: 1.4
Severity: Normal | Resolution: fixed

Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------
Changes (by joaoxsouls <joaoxsouls@…>):

* status: assigned => closed
* resolution: => fixed


Comment:

In [changeset:"1ab27e9a65015373a49688f3ff6723cf85d5de56"]:
{{{
#!CommitTicketReference repository=""
revision="1ab27e9a65015373a49688f3ff6723cf85d5de56"
Fixed #18866 -- added validation error for verbose_name longer than 39
characters

Added a validation error check when creating the permissions for model, to
avoid
cryptic database error when the verbose_name is longer than 39 characters
thanks elena for reporting it
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18866#comment:14>

Django

unread,
Oct 14, 2013, 9:21:06 AM10/14/13
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
------------------------------+------------------------------------
Reporter: elena | Owner: toyg
Type: Bug | Status: closed
Component: contrib.auth | Version: 1.4
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by Marc Tamlyn <marc.tamlyn@…>):

In [changeset:"8ce3c3a9282ac19282060ddf6928b34a09d26672"]:
{{{
#!CommitTicketReference repository=""
revision="8ce3c3a9282ac19282060ddf6928b34a09d26672"
Merge pull request #1733 from joaoxsouls/#18866

Fixed #18866 -- added validation error for verbose_name longer than 39
characters
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18866#comment:15>

Django

unread,
Oct 16, 2013, 11:31:26 AM10/16/13
to django-...@googlegroups.com
#18866: model Meta verbose_name too long error message not obvious
------------------------------+------------------------------------
Reporter: elena | Owner: toyg
Type: Bug | Status: closed
Component: contrib.auth | Version: 1.4
Severity: Normal | Resolution: fixed
Keywords: | Triage Stage: Accepted
Has patch: 1 | Needs documentation: 0
Needs tests: 1 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
------------------------------+------------------------------------

Comment (by Tim Graham <timograham@…>):

In [changeset:"91c77eeab837ff793311ac5b0321015a4e66d6da"]:
{{{
#!CommitTicketReference repository=""
revision="91c77eeab837ff793311ac5b0321015a4e66d6da"
Avoided hardcoding Permission.name max_length

refs #18866.
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/18866#comment:16>

Reply all
Reply to author
Forward
0 new messages