I have a model Property
with certain fields and a relevant method:
class Property(models.Model):
table = models.ForeignKey(Table)
field1 = models.CharField()
field2 = models.IntegerField()
field3 = models.BooleanField()
class Meta:
abstract = True
def post():
pass
But then I have a definite number of types of columns, conceptually speaking. There is no difference in the fields, only in how the behavior of a certain method is implemented:
class Property1(Property):
def post():
# execute behavior for Property1
pass
class Property2(Property):
def post():
# execute behavior for Property2
pass
and so on.
If I turned Property
into an abstract base model class and have the rest inherit it, I will end up with different tables for each property. I am not sure I want that. All tables will look the same, which is redundant.
But at the same time when running a query to get all properties in a table and calling post()
I want the corresponding behavior to be executed:
for prop in table.property_set.all():
prop.post()
What are my options?