Django 没有显示从 cloudinary 上传的图片

Django did not display the uploaded image from cloudinary

我可以知道如何显示从django模板上传到cloudinary的img吗?我试过 {{ obj.img.url }} 但返回错误:属性没有与之关联的文件。我错过了什么吗?

model.py:

class Order(models.Model):
user = models.ForeignKey(settings.AUTH_USER_MODEL, on_delete=models.CASCADE, blank=True, null=True)
wts_img = models.ImageField(upload_to='wts/', blank=True, null=True)

html:

{% load cloudinary %}
{% for order in orders %}
  <img src="{{ order.wts_img.url }}" >
{% endfor %}

setting.py:

CLOUDINARY_STORAGE = {
'CLOUD_NAME': 'xxxxx',
'API_KEY': 'xxxxxxx',
'API_SECRET': 'xxxxxxxxxx'
 }


DEFAULT_FILE_STORAGE = 'cloudinary_storage.storage.MediaCloudinaryStorage'

您可能想查看 list.html on line 31-35 中的 Cloudinary Django 相册示例。 渲染图像标签的示例:

{# THUMBNAIL defined in context_processors #}
{% cloudinary photo.image THUMBNAIL %}