这是追溯
Environment:
Request Method: POST
Request URL: http://mysite.com/admin/content/author/add/
Django Version: 1.4.1
Python Version: 2.7.3
Installed Applications:
('grappelli',
'filebrowser',
'south',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
'tinymce',
'mailchimp',
'content',
'categorization',
'mptt')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware')
Traceback:
File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" in get_response
111. response = callback(request, *callback_args, **callback_kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in wrapper
366. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
91. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/views/decorators/cache.py" in _wrapped_view_func
89. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/sites.py" in inner
196. return view(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapper
25. return bound_func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in _wrapped_view
91. response = view_func(request, *args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py" in bound_func
21. return func(self, *args2, **kwargs2)
File "/usr/local/lib/python2.7/dist-packages/django/db/transaction.py" in inner
209. return func(*args, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in add_view
955. self.save_model(request, new_object, form, False)
File "/usr/local/lib/python2.7/dist-packages/django/contrib/admin/options.py" in save_model
709. obj.save()
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in save
463. self.save_base(using=using, force_insert=force_insert, force_update=force_update)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/base.py" in save_base
551. result = manager._insert([self], fields=fields, return_id=update_pk, using=using, raw=raw)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/manager.py" in _insert
203. return insert_query(self.model, objs, fields, **kwargs)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/query.py" in insert_query
1576. return query.get_compiler(using=using).execute_sql(return_id)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in execute_sql
909. for sql, params in self.as_sql():
File "/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py" in as_sql
872. for obj in self.query.objs
File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/files.py" in pre_save
249. file.save(file.name, file, save=False)
File "/usr/local/lib/python2.7/dist-packages/django/db/models/fields/files.py" in save
86. self.name = self.storage.save(name, content)
File "/usr/local/lib/python2.7/dist-packages/django/core/files/storage.py" in save
45. name = self._save(name, content)
File "/usr/local/lib/python2.7/dist-packages/django/core/files/storage.py" in _save
168. os.makedirs(directory)
File "/usr/lib/python2.7/os.py" in makedirs
150. makedirs(head, mode)
File "/usr/lib/python2.7/os.py" in makedirs
157. mkdir(name, mode)
Exception Type: OSError at /admin/content/author/add/
Exception Value: [Errno 13] Permission denied: '//media/uploads'
这是我的模型
class ArticleImage(models.Model):
title = models.CharField(
verbose_name = _(u'Title'),
help_text = _(u'The title for this article image'),
max_length = 255,
)
alt_text = models.CharField(
verbose_name = _(u'Alt. Text'),
help_text = _(u'The alt text for this article image'),
max_length = 255,
)
image = models.ImageField(
verbose_name = _(u'Image'),
upload_to = 'uploads/articleimages/'
)
article = models.ForeignKey(
Article,
verbose_name = _(u'Article'),
help_text = _(u'The article to which this image belongs'),
)
class Meta:
verbose_name = _(u'Image')
verbose_name_plural = _(u'Images')
def __unicode__(self):
return u'%s'%self.title
以下是相关设置
MEDIA_ROOT = os.getcwd() + '/media/'
MEDIA_URL = '/media/'
DEBUG = False
这是我的媒体目录的 httpd.conf
Alias /media/ /home/quinton/Sites/prod/media/
<Directory /home/quinton/Sites/prod/media>
Order deny,allow
Allow from all
</Directory>
当我在本地运行所有内容时,这不是问题。只有当我推送到我的服务器并重新启动 Apache 时才会发生这种情况。我尝试将媒体目录的文件权限更改为 777,但仍然没有运气。