On Thu, Jan 29, 2009 at 7:36 AM, Oliver Beattie <[email protected]> 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 [email protected]
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