Russell Keith-Magee wrote: > On Wed, May 14, 2008 at 1:09 AM, Carl Karsten <[EMAIL PROTECTED]> wrote: >> [EMAIL PROTECTED]:~/dev/sites/ridgemoor$ ./manage.py loaddata rm.json >> Installing json fixture 'rm' from absolute path. >> Problem installing fixture 'rm.json': columns app_label, model are not >> unique >> >> How do I debug this? > > The error is telling you what is wrong - you are loading data into a > model that has a unique_together clause, but you are loading data that > is not unique together. > > However, I can go a little further in this specific case - you have > contenttypes in your fixture. > > Loading contenttypes by fixture is problematic because all the > contenttypes you will ever need are created automatically as part of > the syncdb. Consider the following sequence of events. > > 1. Create a project, populate INSTALLED_APPS, run syncdb. > 2. Generate a fixture > 3. Add a new application to INSTALLED APPS > 4. Flush the database, rerun syncdb. > 5. Attempt to load the fixture created in 2. > > Since you changed the applications in INSTALLED_APPS in (3), the order > of the contenttypes created in 4 can change (and in your case, _has_ > changed). As a result, the database IDs assigned to the content types > are not consistent, and when you load your fixture, you can end up > with two content type entries for the same content type. > > The simple solution - don't serialize content types. You don't need to > anyway, because they are automatically created by the syncdb process.
What are the chances of getting a dumpdata hack to exclude certain apps? I know it isn't too hard to figure out what apps I want to backup, but it sounds like the 'exclude' feature might be useful even once this issue is resolved. > > The only catch on this is if you are using content types in some way, > and you need to serialize a reference to a content type. The most > likely reason for needing this is if you have a generic relation. In > this case, you are slightly stuck - you can't serialize the generic > relation without guaranteeing the IDs for the content types, but you > can't guarantee the IDs for the content types. This is a known issue, > http://code.djangoproject.com/ticket/7052. > > The only workaround in the meantime is to regenerate or manually tweak > your fixtures every time you modify INSTALLED_APPS. The order in which > contenttypes are created is consistent if you never modify > INSTALLED_APPS, so as long as you are willing to update your fixtures > whenever you modify INSTALLED_APPS, it is possible to live with this > problem. > if INSTALLED_APPS is the same on both boxes, shouldn't it work? (I have a feeling the answer is "maybe" given there might be a problem with the order apps were added or something.) Thanks for the in depth answer. 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 -~----------~----~----~----~------~----~------~--~---