Electronics & Programming

develissimo

Open Source electronics development and programming

  • You are not logged in.

#1 March 27, 2008 07:53:49

Carl K.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

"duplicate key" loading dumpdata


same code on both boxes:

:~/ridgemoor$ ../django/bin/django-admin.py dumpdata
>ridgemoor.json

:~/ridgemoor$ django-admin.py loaddata ridgemoor.json
Installing json fixture 'ridgemoor' from absolute path.
Problem installing fixture 'ridgemoor.json': ERROR: duplicate key violates
unique constraint "django_content_type_app_label_key"

UPDATE "django_content_type" SET
"name"='Categories',"app_label"='eventcal',"model"='eventtype' WHERE "id"=11

um, how did this happen, and how do I fix it?

Carl K

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en-~----------~----~----~----~------~----~------~--~---

Offline

#2 March 27, 2008 09:12:26

Russell K.
Registered: 2009-11-02
Reputation: +  0  -
Profile   Send e-mail  

"duplicate key" loading dumpdata


On Thu, Mar 27, 2008 at 3:52 PM, Carl Karsten <> wrote:
>
> same code on both boxes:
>
> :~/ridgemoor$ ../django/bin/django-admin.py dumpdata
> >ridgemoor.json
>
> :~/ridgemoor$ django-admin.py loaddata ridgemoor.json
> Installing json fixture 'ridgemoor' from absolute path.
> Problem installing fixture 'ridgemoor.json': ERROR: duplicate key violates
> unique constraint "django_content_type_app_label_key"
>
> UPDATE "django_content_type" SET
> "name"='Categories',"app_label"='eventcal',"model"='eventtype' WHERE "id"=11
>
> um, how did this happen, and how do I fix it?

Usually because:

1) You have the contrib.contenttypes table in your database
2) You have added an application to the project
3) The content type IDs that were allocated in the original
application don't match the new application.

The only reliable solution is 'don't serialize the contenttype app'.
The contenttypes are allocated as part of the syncdb process, so
serializing them generally isn't required anyway; in your particular
case, the difference in the order in which contenttypes are allocated
is the cause of the loaddata problem.

This leaves one minor issue - if you have models that reference
content types (for example, generic foreign keys). This is a known
issue, for which there really isn't a good solution - suggestions are
welcome on how this should be worked around.

Yours,
Russ Magee %-)

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to
For more options, visit this group athttp://groups.google.com/group/django-users?hl=en-~----------~----~----~----~------~----~------~--~---

Offline

Board footer

Moderator control

Enjoy the 16th of December
PoweredBy

The Forums are managed by develissimo stuff members, if you find any issues or misplaced content please help us to fix it. Thank you! Tell us via Contact Options
Leave a Message
Welcome to Develissimo Live Support