Django 2.2.3
如何将参数传输到抽象模型的 Meta 内部类?
我的努力:
class GeneralUtmAbstract(models.Model):
where = ""
class Meta:
def __init__(self):
self.verbose_name_plural = "General UTM-labels: {}".format(GeneralUtmAbstract.where)
self.verbose_name = verbose_name_plural
class GeneralUtm(GeneralUtmAbstract):
where = "Both"
class BingUtm(GeneralUtmAbstract):
where = "Bing"
class GoogleUtm(GeneralUtmAbstract):
where = "Google"
我的代码没有引发任何错误。但是冗长的名称并没有按计划显示。我得到“通用 utm”而不是“通用 UTM 标签:两者”。