Django将父对象过滤为子类

时间:2014-06-02 17:30:04

标签: mysql django

我有一个父类和一个带有额外字段的子类。

class Product(models.Model):
    brand = models.CharField(max_length=255)
    productcode = models.CharField(max_length=255)
    price = models.DecimalField(max_digits=7, decimal_places=2)
    keywords = models.CharField(max_length=255)

    class Meta:
        managed = True

class Tent(Product):
    maxcapacity = models.IntegerField(blank=True)
    material = models.CharField(max_length=255)

我通过第三方程序(http://community.pentaho.com/projects/data-integration/)将我的xml数据导入Product MySQL表。当我运行syncdb(或南schemamigrate)时,我希望Tent表自动使用包含关键字" tent"的Product中的对象填充自身。

使用Django 1.6和Python 2.7

0 个答案:

没有答案