Re: "duplicate key" loading dumpdata

2008-03-27 Thread Russell Keith-Magee

On Thu, Mar 27, 2008 at 3:52 PM, Carl Karsten <[EMAIL PROTECTED]> wrote:
>
>  same code on both boxes:
>
>  [EMAIL PROTECTED]:~/ridgemoor$ ../django/bin/django-admin.py dumpdata
>   >ridgemoor.json
>
>  [EMAIL PROTECTED]:~/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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



"duplicate key" loading dumpdata

2008-03-27 Thread Carl Karsten

same code on both boxes:

[EMAIL PROTECTED]:~/ridgemoor$ ../django/bin/django-admin.py dumpdata 
 >ridgemoor.json

[EMAIL PROTECTED]:~/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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---