this has bitten me too recently.

in general I'm moving away from fixtures.  they are breakable, they suffer
when the codebase is refactored.
particularily for tests I no longer use fixtures.

I would suggest trying the dump-to–python-code method




ideally there should be a away to dump a group (or all) objects into some
data structure where all foreign keys are referenced only internally through
some lookup table (that is saved with the objects).

then when loading the structure the objects would be given homes in the
database and the foreign keys would all get resolved into real-world db ids.

there would have to then be a part of the structure that resolved foreign
key ids by a lookup in the host environment where the structure is being
installed (eg looking up the content ids)

the other use for this system would be federating data from site to site.



     felix :    crucial-systems.com



On Thu, Jan 29, 2009 at 12:15 AM, Russell Keith-Magee <
freakboy3...@gmail.com> wrote:

>
> On Thu, Jan 29, 2009 at 7:36 AM, Oliver Beattie <oli...@obeattie.com>
> wrote:
> >
> > How can I be sure that the ContentType IDs are always constant, and
> > therefore my data in fixtures is guaranteed to always point to the
> > right object?
>
> Oliver, meet ticket #7052. Ticket #7052, meet Oliver :-)
>
> This is an annoying bug that I have wanted to address for a while. The
> ticket describes an approach that I believe will work, but doesn't
> contain a patch. On IRC a few days back, Eric Holscher mentioned that
> he had a nasty hack that implemented a fix for this. I don't know how
> far that hack has gone, or if he will be willing to share code.
>
> The best workaround that I can suggest is to include your ContentTypes
> in your fixtures. They are dumpable objects, just like everything else
> in Django. If your fixture contains the content types, it doesn't
> matter what primary key values are automatically created, because they
> will be overwritten by the fixture. You shouldn't get any duplicate
> primary key errors because the fixtures framework overwrites existing
> objects with the same primary key. The only time you need to be
> careful is when you start adding new models, and new content types are
> created - if you don't update your fixtures, you could get some
> interesting side effects.
>
> 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 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to