Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fixed #1802 -- Fixed database integrity error when creating permissio…

…n objects after renaming a model

git-svn-id: bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit fb1c01b1038cbba421aaaf5b53da5bb507cc9b48 1 parent 37addba
@adrianholovaty adrianholovaty authored
Showing with 3 additions and 5 deletions.
  1. +3 −5 django/contrib/auth/
8 django/contrib/auth/
@@ -25,11 +25,9 @@ def create_permissions(app, created_models):
for klass in app_models:
ctype = ContentType.objects.get_for_model(klass)
for codename, name in _get_all_permissions(klass._meta):
- try:
- Permission.objects.get(name=name, codename=codename,
- except Permission.DoesNotExist:
- p = Permission(name=name, codename=codename, content_type=ctype)
+ p, created = Permission.objects.get_or_create(codename=codename,,
+ defaults={'name': name, 'content_type': ctype})
+ if created:
print "Adding permission '%s'" % p
def create_superuser(app, created_models):
Please sign in to comment.
Something went wrong with that request. Please try again.