gpt4 book ai didi

django - 上载文件时Django的权限被拒绝错误

转载 作者:行者123 更新时间:2023-12-03 11:30:51 31 4
gpt4 key购买 nike

我目前定义了一个简单的模型,使用django thumbnails插件具有photoupload功能。

但是当我尝试上传时,出现以下错误:

OSError at /admin/products/photo/add/

(13, 'Permission denied')

现在,我知道这似乎是一个权限问题,因此我检查的第一件事是目录权限,并将其更改为777(仅用于测试),重新启动了服务器和fcgi,仍然显示错误。

追溯
Traceback: File "/usr/lib/python2.6/dist-packages/django/core/handlers/base.py" in get_response
92. response = callback(request, *callback_args,
**callback_kwargs) File "/usr/lib/python2.6/dist-packages/django/contrib/admin/options.py" in wrapper
226. return self.admin_site.admin_view(view)(*args,
**kwargs) File "/usr/lib/python2.6/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
44. response = view_func(request, *args, **kwargs) File "/usr/lib/python2.6/dist-packages/django/contrib/admin/sites.py" in inner
186. return view(request, *args, **kwargs) File "/usr/lib/python2.6/dist-packages/django/db/transaction.py" in _commit_on_success
240. res = func(*args, **kw) File "/usr/lib/python2.6/dist-packages/django/contrib/admin/options.py" in add_view
734. self.save_model(request, new_object, form, change=False) File "/usr/lib/python2.6/dist-packages/django/contrib/admin/options.py" in save_model
557. obj.save() File "/usr/lib/python2.6/dist-packages/django/db/models/base.py" in save
410. self.save_base(force_insert=force_insert, force_update=force_update) File "/usr/lib/python2.6/dist-packages/django/db/models/base.py" in save_base
483. values = [(f, f.get_db_prep_save(raw and getattr(self, f.attname) or f.pre_save(self, True))) for f in meta.local_fields if not isinstance(f, AutoField)] File "/usr/lib/python2.6/dist-packages/django/db/models/fields/files.py" in pre_save
252. file.save(file.name, file, save=False) File "/var/www/django_projects/gang/../gang/products/thumbs.py" in save
84. super(ImageWithThumbsFieldFile, self).save(name, content, save) File "/usr/lib/python2.6/dist-packages/django/db/models/fields/files.py" in save
91. self.name = self.storage.save(name, content) File "/usr/lib/python2.6/dist-packages/django/core/files/storage.py" in save
47. name = self._save(name, content) File "/usr/lib/python2.6/dist-packages/django/core/files/storage.py" in _save
146. os.makedirs(directory) File "/usr/lib/python2.6/os.py" in makedirs
150. makedirs(head, mode) File "/usr/lib/python2.6/os.py" in makedirs
150. makedirs(head, mode) File "/usr/lib/python2.6/os.py" in makedirs
150. makedirs(head, mode) File "/usr/lib/python2.6/os.py" in makedirs
157. mkdir(name, mode)

Exception Type: OSError at /admin/products/photo/add/ Exception Value: (13, 'Permission denied')

运行FCGI守护程序的用户绝对有权读取和写入该目录。

来自settings.py
MEDIA_ROOT = '/var/www/sites/gang/http/media/'
MEDIA_ROOT_URL = '/media/'

最佳答案

尝试检查以/开头的路径中每个目录的权限。只是一个想法。

关于django - 上载文件时Django的权限被拒绝错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1682440/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com