On Tue, Mar 4, 2008 at 3:59 PM, Evan H. Carmi <[EMAIL PROTECTED]> wrote: > > Hi, > > I am trying to loaddata from a file, bmdata.xml and getting an error: > Problem installing fixture 'bmdata.xml': duplicate key violates unique > constraint "django_content_type_app_label_key" > > I understand that there is a conflict in the fixture data. However, I > don't know how to solve it. I only ran syncdb before loaddata, and did > not create any content.
Hi Evan, The catch is that you _did_ create content - you just don't know that you did because it happens in the background. When you run syncdb, various triggers are fired that stimulate the creation of certain initial data. Of particular interest in this case are the content types. Each model you have in your project generates a content type so that the models can be referred to in a generic manner by other parts of Django. There isn't really any way to control the content types that are allocated. As a result, if you change the applications that are installed, or the order in which they are installed, the content types can change. If you generate a fixture on an old database, modify the installed apps, re-synchronize your database, then load your fixture, the old content types can potentially cause a conflict - the error you are seeing is one such potential problem. The only real solution at present is to avoid serializing content types whenever possible (i.e., by not dumping the contenttypes application). If your fixture already has content types, manually delete them from the fixture before loading. This is a known crusty area associated with fixtures. Unfortunately, it isn't a trivial problem to fix. Suggestions on how to improve this aspect of Django are most welcome. 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 -~----------~----~----~----~------~----~------~--~---