Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Fix for #18866: added check and improved error message for syncdb error ... #1140

Closed
wants to merge 1 commit into from

2 participants

@djangsters

...when using models with verbose_name longer than 50 chars

Iwan Trofimtschuk Fix for #18866: added check and improved error message for syncdb err…
…or when using models with verbose_name longer than 50 chars
255f15b
@timgraham
Owner

As noted in the ticket, this needs a test. Please re-open this request or open a new one when that's complete.

@timgraham timgraham closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 18, 2013
  1. Fix for #18866: added check and improved error message for syncdb err…

    Iwan Trofimtschuk authored
    …or when using models with verbose_name longer than 50 chars
This page is out of date. Refresh to see the latest.
Showing with 11 additions and 0 deletions.
  1. +11 −0 django/contrib/auth/management/__init__.py
View
11 django/contrib/auth/management/__init__.py
@@ -94,6 +94,17 @@ def create_permissions(app, created_models, verbosity, db=DEFAULT_DB_ALIAS, **kw
for ctype, (codename, name) in searched_perms
if (ctype.pk, codename) not in all_perms
]
+ # Validate the permissions before bulk_creation to avoid cryptical
+ # Database error when the verbose_name is longer than 50 charachters
+ for perm in perms:
+ try:
+ perm.full_clean()
+ except exceptions.ValidationError:
+ print("Creating permission %s for %s not possible" %
+ (perm.codename, '.'.join(perm.content_type.natural_key())))
+ print("Is the verbose_name of %s longer than 50 charachters?" %
+ '.'.join(perm.content_type.natural_key()))
+ raise
auth_app.Permission.objects.using(db).bulk_create(perms)
if verbosity >= 2:
for perm in perms:
Something went wrong with that request. Please try again.