我有models.py
分钱:
class Item(models.Model):
image_file = models.ImageField(upload_to='images')
image_url = models.URLField()
我希望Django自动下载和本地保存图像从image_url
和连接它与image_file
How it should act:个
- 我贴
https://docs.djangoproject.com/s/img/site/hdr_logo.gif
- 单击"保存"
- 在模板中写
<img src="{{ item.image_file.url }}">
.它显示出 来self 的服务器的图像,而不是djangoproject.com
What I've tried:
我已经改写了Item
类的save
个方法.我通过urllib
在本地保存了图像,但我坚持将此保存的图像与image_file
字段连接起来