如何通过cloudinary Django SDK响应图像?

时间:2019-04-06 13:50:02

标签: python django cloudinary

我正在开发django项目。我想通过cloudinary django SDK响应一些图像。

-这有效,但没有响应

```index.html
{% load cloudinary %}

  {% cloudinary post.image.url width=200 %}
```

-为响应,我尝试了此操作,但没用。

```base.html & index.html
<head>
~~~
  <script
      src="cloudinary-core-shrinkwrap.js"
      type="text/javascript">
  </script>
</head>

<body>
{% load cloudinary %}

{% cloudinary post.image.url crop="fill" width="auto" %}
~~~
<script type="text/javascript">
    var cl = cloudinary.Cloudinary.new({cloud_name: "xxxx"});
    cl.responsive();
</script>
</body>

版本: Django版本:2.1.4 Python版本:3.7.2 本地主机

再次输入我的代码...

```settings.py
INSTALLED_APPS = [
    ...
    'cloudinary',
    'cloudinary_storage',
]
```

```base.html
<head>
  <!--cloudinary -->
  <script
      src="cloudinary-core-shrinkwrap.js"
      type="text/javascript">
  </script>
</head>

<body>

{% block content %}
{% endblock %}

~~~
<!--cloudinary -->
<script type="text/javascript">
    var cl = cloudinary.Cloudinary.new({cloud_name: "hmtmgjlio"});
    cl.responsive();
</script>
</body>
```

```index.html
{% extends 'base.html' %}
{% load cloudinary %}

  {% cloudinary post.image.url crop="fill" width="auto" %}

```

我希望django SDK这样提供img标签。

  

django官方SDK   https://cloudinary.com/documentation/django_image_manipulation

0 个答案:

没有答案