【发布时间】:2021-02-11 10:03:25
【问题描述】:
我发现了类似的问题和答案,但似乎没有一个是完全正确的。我有一个像这样的抽象基础模型:
class BaseModel(models.Model):
timestamp = models.DateTimeField(auto_now_add=True)
modified = models.DateTimeField(auto_now=True)
description = models.CharField(max_length=512, blank=True, null=True, help_text='Help')
class Meta:
abstract = True
然后我继承它:
class AnotherModel(BaseModel):
field1 = models.CharField(max_length=512)
但我希望 description 字段上的这个模型的 help_text 是别的东西,比如 help_text='Some other help text'
最好的方法是什么?我可以覆盖继承模型的字段选项吗?
【问题讨论】:
标签: django inheritance django-models django-model-field