我使用的是Django 1.11.11/python2.7.5 我有一个照片模型在形式上传多个图片。此模型有错误:https://ibb.co/m3XLDn
照片型号:
class Photo(models.Model):
produit = models.CharField(
_("Produit (code utile pour le tri des choix):"),
max_length=2000,
blank=True,
null=False
)
legende = models.CharField(
_("Légende:"),
max_length=200,
blank=True,
null=False
)
image = models.ImageField(
upload_to='fiche_image',
blank=True,
null=False
)
def __str__(self):
return self.produit or "undefined"
# return str(self.produit)
class Meta:
ordering = ['produit', 'legende', 'image']
我不知道是什么引起了这个问题。在
新照片视图:
^{pr2}$
您没有与
Photo
对象关联的文件。因此,它抛出了一个错误,它说“'image'属性没有与之关联的文件”。因为字段image
允许存储空值。在这种情况下,Photo
对象将没有关联的文件。在你可以像下面这样检查
相关问题 更多 >
编程相关推荐