django3文件上传默认权限是420?

django3 file upload default permission is 420?

我把佣人图片上传功能作为购物管理。

网络: http://www.henojiya.net/shopping/

来源: https://github.com/duri0214/Portfolio/tree/master/mysite/shopping

现在,我来解决这个问题。 权限错误。

日志: https://github.com/duri0214/Portfolio/issues/25

我正在查看日志消息。

FILE_UPLOAD_DIRECTORY_PERMISSIONS   
None
FILE_UPLOAD_PERMISSIONS 
420

420???

我认为 django 默认权限是 644。

官方文档: https://docs.djangoproject.com/en/3.0/ref/settings/#file-upload-permissions

本地上传测试ok! 我要上传图片

谢谢

add info
drwxr-xr-x. op op mysite
└drwxrwxr-x. op op shopping
 └drwxrwxr-x. op op static
  └drwxrwxr-x. op op shopping
   └drwxrwxr-x. op op img

好的!我修好了。

我不知道 "media" 在 "setting.py" 中的作用。
如果添加写入 'setting.py'
,django 想要保存到 '[example.com]/media' 我没有编辑apache文件。

# setting.py
MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = '/media/'

在'models.py'中,如果设置了upload_to='shopping/',则保存为[example.com] /media/shopping/xxx.jpg

# models.py
class Products(models.Model):
    """product"""
    code = models.CharField('code', max_length=200)
    name = models.CharField('product_name', max_length=200)
    price = models.IntegerField('product_price', default=0)
    description = models.TextField('description')
    picture = models.ImageField('picture', upload_to='shopping/')