【发布时间】:2018-04-14 07:55:37
【问题描述】:
我有一个现有的数据库表,其中 ImageField 已经有一堆现有的注册表。我想在我的模型上添加image_width 和image_height,但我需要一些东西来自动填充现有的表格。
class ItemImage(models.Model):
file = models.ImageField(upload_to=image_directory_path, width_field='image_width', height_field='image_height')
image_width = models.IntegerField()
image_height = models.IntegerField()
我在文档中看到image_width 和image_height 在save() 上时会自动生成,但现有图像已经保存。
【问题讨论】:
标签: django python-3.x django-models