On Sat, Nov 8, 2008 at 5:13 AM, Dana <[EMAIL PROTECTED]> wrote:
>
> Hey everyone,
>
> I just set up a few fixtures for some of my models and realized that
> every time I syncdb it changes the existing data in my database. I
> assume this is normal behavior, but I was wondering if it is possible
> to have the fixtures only *add* data and not change it?

The initial data fixture is reloaded every time that syncdb is
executed; this will overwrite any changes that have been made to that
initial data. This is normal, intended behaviour, and there isn't a
setting or option to change this behaviour.

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.

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.

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
-~----------~----~----~----~------~----~------~--~---

Reply via email to