I am trying to ./manage.py dumpdata --natural-foreign --natural-primary
my classes, which are:
class SuperClassManager(Manager):
def get_by_natural_key(self, identifier):
return self.get(identifier=identifier)
class SuperClass(Model):
objects = SuperClassManager()
identifier = CharField(max_length=31, unique=True)
def natural_key(self):
return (self.identifier, )
class Class(SuperClass):
pass
But the dumped data is:
[
{
"model": "app.superclass",
"fields": {
"identifier": "identifier"
}
},
{
"model": "app.class",
"fields": {}
}
]
There's no way to relate the Class
instance to the SuperClass
instance in this case. What am I missing? Why isn't the superclass_ptr
existent in Class
(which points to SuperClass
) being serialized so it is possible to relate the instances?
Problem being: I have more than one subclass to my superclass and many instances of each subclass. So I need this relation to happen so my fixtures will make sense.
This is actually a bug, and the patch is under construction: https://github.com/django/django/pull/7231. So, no answer appropriate for this question, except wait for the patch.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With