On Sat, Nov 8, 2008 at 1:19 PM, Dana Woodman <[EMAIL PROTECTED]> wrote: > >> Having an option to add data in the way you describe isn't really a >> good idea. If the syncdb behaviour was changed to add rather than >> overwrite initial data, you would have a different (and IMHO much >> worse) consequence - each time you run syncdb, you will end up with >> another copy of the initial data. If you run syncdb 100 times, you >> would end up with 100 copies of each fixture object. > > What I was envisioning was a solution that would check if the PK existed, if > it did, it would pass, if not, it would add the rows. The intended use was > to populate a database at first go with the needed data, but still be able > to run syncdb without mucking things up. Guess I'll have to go the other > route.
This idea is a little more sound, and is certainly in the realm of the possible. I have some plans to improve fixture loading as a part of my work on ticket #7052; Adding a --noclobber option would be a reasonable extension to this work. I would suggest opening a ticket so that the idea isn't forgotten. If you want to work on a patch, that would be even better. >> The purpose behind the initial data fixture is to provide *absolutely >> essential* initial data that must exist in order for the database to >> work - for example, the root node of a tree structure. If you have >> other data that is required to bootstrap the system - especially if >> that data is subject to change over the lifespan of the website - >> define that data in a fixture other that initial_data (say >> bootstrap_data), and manually load that fixture using loaddata. That >> way the bootstrap data will only be loaded (and therefore overwritten) >> when you explictly request a reload. > > Thanks, that is good advice, I will go ahead and do that. That will > accomplish just about what I am looking for. > > Would it suffice to just rename the file/folder to > bootstrap_data/bootstrap_data.json? Does Django look for a file called > initial_data.json in a folder called initial_data, or does it just look for > any file called initial_data.json? Django looks for a file called initial_data.* in each of the <app>/fixture directories, plus each of the directories mentioned in settings.FIXTURE_DIRS, plus the current working directory. The same rules apply for any other fixture name. So - if you can currently load initial_data.json, renaming it bootstrap.json is all you need to do. Django's fixture loader doesn't use directory names as part of the lookup scheme unless explicitly instructed to do so as part of the settings.FIXTURE_DIRS option. Unless you particularly want to have your fixtures in separate directories, there is no need to move initial_data into a different directory. 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 -~----------~----~----~----~------~----~------~--~---