我安装了django-filer,现在正在测试上传功能,但是当我尝试上传文件时,我收到以下错误:
[Fri Jul 10 11:32:20 2015] [error] ERROR Internal Server Error: /admin/filer/clipboard/operations/upload/
[Fri Jul 10 11:32:20 2015] [error] Traceback (most recent call last):
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 112, in get_response
[Fri Jul 10 11:32:20 2015] [error] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/views/decorators/csrf.py", line 57, in wrapped_view
[Fri Jul 10 11:32:20 2015] [error] return view_func(*args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/filer/admin/clipboardadmin.py", line 81, in ajax_upload
[Fri Jul 10 11:32:20 2015] [error] file_obj.save()
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/filer/models/imagemodels.py", line 56, in save
[Fri Jul 10 11:32:20 2015] [error] super(Image, self).save(*args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/filer/models/abstract.py", line 65, in save
[Fri Jul 10 11:32:20 2015] [error] super(BaseImage, self).save(*args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/filer/models/filemodels.py", line 165, in save
[Fri Jul 10 11:32:20 2015] [error] super(File, self).save(*args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/polymorphic/polymorphic_model.py", line 89, in save
[Fri Jul 10 11:32:20 2015] [error] return super(PolymorphicModel, self).save(*args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 545, in save
[Fri Jul 10 11:32:20 2015] [error] force_update=force_update, update_fields=update_fields)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 572, in save_base
[Fri Jul 10 11:32:20 2015] [error] self._save_parents(cls, using, update_fields)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 597, in _save_parents
[Fri Jul 10 11:32:20 2015] [error] self._save_table(cls=parent, using=using, update_fields=update_fields)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 654, in _save_table
[Fri Jul 10 11:32:20 2015] [error] result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 687, in _do_insert
[Fri Jul 10 11:32:20 2015] [error] using=using, raw=raw)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/manager.py", line 232, in _insert
[Fri Jul 10 11:32:20 2015] [error] return insert_query(self.model, objs, fields, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/query.py", line 1514, in insert_query
[Fri Jul 10 11:32:20 2015] [error] return query.get_compiler(using=using).execute_sql(return_id)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 902, in execute_sql
[Fri Jul 10 11:32:20 2015] [error] for sql, params in self.as_sql():
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 860, in as_sql
[Fri Jul 10 11:32:20 2015] [error] for obj in self.query.objs
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/fields/files.py", line 252, in pre_save
[Fri Jul 10 11:32:20 2015] [error] file.save(file.name, file, save=False)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/filer/fields/multistorage_file.py", line 95, in save
[Fri Jul 10 11:32:20 2015] [error] super(MultiStorageFieldFile, self).save(name, content, save)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/easy_thumbnails/files.py", line 667, in save
[Fri Jul 10 11:32:20 2015] [error] super(ThumbnailerFieldFile, self).save(name, content, *args, **kwargs)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/db/models/fields/files.py", line 86, in save
[Fri Jul 10 11:32:20 2015] [error] self.name = self.storage.save(name, content)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/core/files/storage.py", line 49, in save
[Fri Jul 10 11:32:20 2015] [error] name = self._save(name, content)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib/python2.6/site-packages/django/core/files/storage.py", line 172, in _save
[Fri Jul 10 11:32:20 2015] [error] os.makedirs(directory)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib64/python2.6/os.py", line 150, in makedirs
[Fri Jul 10 11:32:20 2015] [error] makedirs(head, mode)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib64/python2.6/os.py", line 150, in makedirs
[Fri Jul 10 11:32:20 2015] [error] makedirs(head, mode)
[Fri Jul 10 11:32:20 2015] [error] File "/usr/lib64/python2.6/os.py", line 157, in makedirs
[Fri Jul 10 11:32:20 2015] [error] mkdir(name, mode)
[Fri Jul 10 11:32:20 2015] [error] OSError: [Errno 13] Permission denied: '/home/uronline/media/filer_public/3b'
我已经看过其他一些提到这个问题的问题,这就是我所检查的内容:
的httpd.conf
<VirtualHost *:80>
Alias /media/ /home/uronline/media/
<Directory /home/uronline/media>
Order deny,allow
Allow from all
</Directory>
</VirtualHost>
settings.py
MEDIA_ROOT = os.path.join(PROJECT_ROOT, 'media')
MEDIA_URL = '/media/'
我正在使用Apache,用户是apache
“media”文件夹路径中的所有文件夹都设置为755,用户:apache,group:www
出于好奇,我暂时将文件夹权限更改为777并仍然出错。
我正在使用django-filer的默认设置,我现在想知道这个权限错误是否是由此引起的?
任何帮助都会非常感激。谢谢。
答案 0 :(得分:0)
好的,我明白了!和往常一样,我的问题是SELinux
结果显示selinux有一个布尔值“允许httpd守护程序在标记为public_content_rw_t的目录中写入文件” - 来自http://wiki.centos.org/TipsAndTricks/SelinuxBooleans
所以这很有效:
setsebool -P allow_httpd_anon_write on
希望这有助于某人!