I'm looking for right ways to override the create() method of a subclass.
Basically I'm doing this:
class Base(models.Model):
field1_base = models.IntegerField()
def __init__(self, field1_base):
# LOGICS
self.field1_base = field1_base
class A(Base):
field2_sub = models.IntegerField()
def __init__(self, field2_sub, field1_base):
# LOGICS
self.field2_sub = field2_sub
super(A, self).__init__(field1_base)
A(field2_sub=1, field1_base=2)
However we can't override the __init__() method of a model.
I just want to leave some fields to be assigned in base class's methods.
Is there a proper way to do this using create() method?
Of course I can custom create method of Base class, however what I want is to invoke Base.create and A.create at the same time on the creation of A, which makes the situation different from this question
super(A, self).create()then? Or you want to create Base and A objects at the same time with A.create()?