【问题标题】:Cloudinary Image Upload errpr in django python while hosted in pythonanywhere在 pythonanywhere 中托管时,django python 中的 Cloudinary Image Upload 错误
【发布时间】:2022-01-06 05:13:49
【问题描述】:

所以我使用 pythonanywhere 托管一个 django 网站,在该网站上上传图片并显示上传的图片存储在 cloudinary 中,显示图片工作正常,但是当我上传帖子时出现此错误:

Error at /post/
Unexpected error - MaxRetryError("HTTPSConnectionPool(host='api.cloudinary.com', port=443): Max retries exceeded with url: /v1_1/meme-topia/image/upload (Caused by NewConnectionError('<urllib3.connection.HTTPSConnection object at 0x7f8d77f41370>: Failed to establish a new connection: [Errno 111] Connection refused'))")

模型文件:

from django.db import models
from cloudinary.models import CloudinaryField


# Create your models here.
class MemeImg(models.Model):
    Title = models.CharField(max_length=500)
    Post_Img = CloudinaryField('image')

    def __str__(self):
        return self.Title

表格文件:

from django import forms
from .models import MemeImg


class PostImg(forms.ModelForm):
    class Meta:
        model = MemeImg
        fields = '__all__'

然后是源码链接:https://github.com/Shadow-Knight503/memoster503.git

请帮忙

【问题讨论】:

标签: python django cloudinary pythonanywhere


【解决方案1】:

你确定你的 settings.py 中有这个吗?

    CLOUDINARY = {
      'CLOUD_NAME': 'CLOUD-NAME',  
      'API_KEY': 'xx',  
      'API_SECRET': 'xx',
      'API_PROXY': 'http://proxy.server:3128'
}

【讨论】:

  • 不让我试试非常感谢
  • 我做到了,我收到了这个错误:在 /post/ 配置不当 为了使用云存储,您需要在设置中提供带有 CLOUD_NAME、API_SECRET 和 API_KEY 的 CLOUDINARY_STORAGE 字典或设置 CLOUDINARY_URL 变量(或 CLOUDINARY_CLOUD_NAME、CLOUDINARY_API_KEY、CLOUDINARY_API_SECRET 变量)。
  • 请帮帮我,
【解决方案2】:

我相信键应该是小写的。万无一失的方法是转到您的仪表板并下载您的 python 设置:

settings.py 应该是这种格式:

CLOUDINARY = {
      'cloud_name': 'CLOUD-NAME',  
      'api_key': 'xx',  
      'api_secret': 'xx',
      'api_proxy': 'http://proxy.server:3128'
}

【讨论】:

  • 很高兴它成功了!支持它,以便其他人也可能受益;)
  • 对不起,我没有足够的声望来投票
猜你喜欢
  • 1970-01-01
  • 2020-12-16
  • 2017-05-05
  • 2021-11-28
  • 1970-01-01
  • 1970-01-01
  • 2018-04-11
  • 1970-01-01
  • 2021-08-12
相关资源
最近更新 更多