我的foreignkeyfield的verbose_name
没有打印在我的表单中。 (我通过modelformset_factory
创建模型形式
模型
class MOrders(models.Model):
amount = models.IntegerField('Bestellmenge', null=True, blank=True)
order_date = models.DateField('Bestelldatum')
id = models.AutoField(primary_key=True)
m_product_types = models.ForeignKey(MProductTypes)
class Meta:
db_table = u'm_orders'
verbose_name = 'Bestellung'
verbose_name_plural = 'Bestellungen'
unique_together = (('id','order_date','m_product_types'))
def __unicode__(self):
return "%s" % (self.order_date)
设置了
verbose_name
的m_product_types
。乙class MProductTypes(models.Model):
id = models.AutoField(primary_key=True)
stock = models.IntegerField('Bestand',null=True, blank=True)
m_products = models.ForeignKey(MProducts, verbose_name='Produkt')
m_sizes = models.ForeignKey(MSizes, verbose_name='Groesse')
m_colors = models.ForeignKey(MColors, verbose_name='Farbe')
class Meta:
verbose_name = u'Produktart'
verbose_name_plural = 'Produktarten'
db_table = u'm_product_types'
难道我做错了什么?我从主干使用最新的Django版本。
最佳答案
m_product_types = models.ForeignKey(MProductTypes,
verbose_name = u'Produktart',
)
关于python - Foreignkeyfield-详细名称未在表单中显示,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/3587613/