I have a supplied database schema for which I want to create a Django application. Many of the tables in the schema share a common set of columns, such as name
and date_created
. That prompted me to create an abstract Standard_model
class containing those columns, and subclass the relevant models from it.
Unfortunately, some of the tables have a name
column with a different max_length
. I'm trying to come up with a way for the subclassed model to pass the max_length
value to the abstract base class, but I'm drawing a blank.
Any ideas?
class Standard_model(models.Model):
name = models.CharField(max_length=50)
date_created = models.DateTimeField()
class Meta:
abstract = True
class MyModel(Standard_model):
name = models.CharField(max_length=80) # Can't do this.