Foreignkeyfield - 详细名称未在表单中显示

时间:2010-08-27 19:43:42

标签: python django django-models

我的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'

我做错了吗?我正在使用trunk中最新的Django版本。

1 个答案:

答案 0 :(得分:12)

m_product_types = models.ForeignKey(MProductTypes, 
                                    verbose_name = u'Produktart',
                                   )