I am trying to create a Django ORM mapping compatible with an existing data model , so I am trying to work with an existing set of table and column names.
I have an inheritance situation with multiple tables where the InformationObject class comes from the Object class. I would like Django to handle this in the usual way:
class Object(models.Model): class Meta: db_table = "object" class InformationObject(Object): class Meta: db_table = "information_object"
In this case, Django will automatically create a one-to-one field in the inheriting model named object_ptr_id . However, in the scheme I am forced to use, the object reference is simply called "id". So:
Is there any way to specify the name of a Django column automatically used for multi-valued inheritance?
An alternative that I should use otherwise is to use an explicit one-to-one field, but then I will not be able to inherit methods other than the database from the object model:
class Object(models.Model): class Meta: db_table = "object" class InformationObject(models.Model): class Meta: db_table = "information_object" id = models.OneToOneField(Object, primary_key=True, db_column="id")
Any ideas? Perhaps I could create a common base class for both of them and put non-db methods there ...?
source share