No. The difficulty here is that you wouldn't ever be able to have
relations between models, since they refer to each other using the
primary key values (almost always).
Regards,
Malcolm
--
The early bird may get the worm, but the second mouse gets the cheese.
http://www.pointy-stick.com/blog/
Feel free to make this modification to your own Django install.
However such a change would not be accepted for inclusion in the
Django trunk. Django serialized data _must_ be able to include
references to other instances.
I'm not fundamentally opposed to the idea you are suggesting -
however, any proposal to change the serializers to accomodate loading
data without specifying PK's will need to provide a solution to the
general problem, not just a "it works as long as you don't reference
other instances" solution.
Yours,
Russ Magee %-)
I think you're misunderstanding. There's no bug or issue here, at least
as far as you've explained it. Django's loaddata simply isn't designed
for data that isn't fully specified, which includes the pk value.
Instead, it's designed to handle the stuff written out by dumpdata.
If you want to load data that has some slightly different format, as
you've indicated, I wouldn't be looking at loaddata at all -- that's too
specialised. I'd be subclassing the appropriate serializer class and
overriding a few of the methods to look up the starting pk value and
fill them in. That requires no changes to core at all and should be
reasonably straightforward: the serializers (including the deserializer
classes, which is what you're talking about here) are state-based
parsing machines. So it's a matter of putting your hooks into the right
states. They're pretty well documented and there are four examples
already (json, yaml, python and xml) to get you started.
It really sounds like subclassing the deserializer for whichever format
you're using would be the "correct" place to solve this.
Regards,
Malcolm
--
If you think nobody cares, try missing a couple of payments.
http://www.pointy-stick.com/blog/