This is a well known, well understood problem with at least one
solution that has been designed, but not implemented:
http://code.djangoproject.com/ticket/7052
In short, the solution I have historically preferred is to modify the
serialization language to allow queries to take the place of literal
primary keys - that way, you can ask in a fixture for "the article
content type", rather than content type 37.
However, I am open to other suggestions. Eric Holscher has been
working in this area recently, and he has made some interesting
progress with some slightly different approaches.
> Possible solution that doesn't suck a lot:
> I came up with quite a few different ways to handle this, but the best
> so far (even thought it's not stellar) is to create a new column in
> contenttypes that's a combined column. The combined column would
> contain the app_label and model_name.
This has been proposed in the past, but is problematic because it is
backwards incompatible. There is a very large existing codebase that
uses the current implementation of ContentType; changing this model
would be non-trivial.
Yours,
Russ Magee %-)
This is a great solution; when I wrote this post I was sure no one had
really run into the problem. I will use this for serializing my DB in
the future. Though, the last paragraph of your reply states that
content type doesn't define app_label and model as unique. I believe
that this is true now, at least mine appears to have a unique
constraint on it right away.
This is still a legitimate issue during serialization, it's great to
see someone has made steps in the right direction.