Opened 13 years ago

Closed 13 years ago

Last modified 13 years ago

#1802 closed defect (fixed)

changing description name gives error with

Reported by: mdt@… Owned by: Adrian Holovaty
Component: contrib.admin Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no


after changing the verbose_name, a syncdb gave an error:

Traceback (most recent call last):
  File "./", line 11, in ?
  File "django/core/", line 1237, in execute_manager
  File "django/core/", line 1163, in execute_from_command_line
  File "django/core/", line 473, in syncdb
    app=app, created_models=created_models)
  File "django/dispatch/", line 347, in send
  File "django/dispatch/", line 47, in robustApply
    return receiver(*arguments, **named)
  File "django/contrib/auth/", line 34, in create_permissions
  File "django/db/models/", line 185, in save
    ','.join(placeholders)), db_values)
  File "django/db/backends/", line 12, in execute
    return self.cursor.execute(sql, params)
  File "django/db/backends/sqlite3/", line 74, in execute
    return Database.Cursor.execute(self, query, params)
pysqlite2.dbapi2.IntegrityError: columns content_type_id, codename are not unique

content of the table is:

sqlite> select * from auth_permission;
31|Can add TrainingsTagebuch|11|add_trainingstagebuch
32|Can change TrainingsTagebuch|11|change_trainingstagebuch
33|Can delete TrainingsTagebuch|11|delete_trainingstagebuch

executed sql is:

SELECT "auth_permission"."id","auth_permission"."name","auth_permission"."content_type_id","auth_permission"."codename" FROM "auth_permission" WHERE ("auth_permission"."codename" = ? AND "auth_permission"."name" = ? AND "auth_permission"."content_type_id" = ?) ['add_trainingstagebuch', u'Can add Eintrag im Trainingstagebuch', 11]
INSERT INTO "auth_permission" ("name","content_type_id","codename") VALUES (?,?,?) [u'Can add Eintrag im Trainingstagebuch', 11, 'add_trainingstagebuch']

because the name is used in the where lookup django does not find the record and tries to insert a new one.

Change History (2)

comment:1 Changed 13 years ago by mdt

fix in django/contrib/auth/ instead of:

Permission.objects.get(name=name, codename=codename,



perhaps one should add a way to reflect the new name also here.

comment:2 Changed 13 years ago by Adrian Holovaty

Resolution: fixed
Status: newclosed

(In [3172]) Fixed #1802 -- Fixed database integrity error when creating permission objects after renaming a model

Note: See TracTickets for help on using tickets.
Back to Top