我想创建一个从我的模型继承的表单,但它不起作用,我不知道为什么。
它不会抛出任何异常,只是不显示指定的字段。
模型.py
class Picture(models.Model):
picture = models.ImageField(upload_to='/')
name = models.CharField(max_length=30)
owner = models.ForeignKey(Artist)
date = models.DateField()
description = models.CharField(max_length=1000)
width = models.IntegerField(max_length=9)
height = models.IntegerField(max_length=9)
sold = models.BooleanField(default=False)
added = models.DateTimeField(auto_now_add=True)
active = models.BooleanField(default=False)
genres = models.ManyToManyField(Genre)
def __unicode__(self):
return u'%s from %s by %s' % (self.name, self.date, self.owner)
表格.py
class PictureForm(forms.Form):
class Meta:
model = Picture
fields = ('picture', 'name', 'date', 'description', 'width', 'height')
我错过了什么,还是有一个普遍的错误?