我正在尝试构建一个 django 应用程序并将其托管在 webfaction 上。
我的模型如下所示:
class Post(models.Model):
title = models.CharField(max_length=512)
image = models.ImageField(upload_to='blogImages/')
body = models.TextField()
visible = models.BooleanField()
date_created = models.DateTimeField(auto_now_add=True)
date_updated = models.DateTimeField(auto_now=True)
tags = models.ManyToManyField('Tag', null=True, blank=True)
def __unicode__(self):
return self.title
设置如下所示:
MEDIA_ROOT = '/home/myself/webapps/dev_static/media/'
MEDIA_URL = 'http://dev.example.com/static/media/'
STATIC_ROOT = '/home/myself/webapps/dev_static/'
STATIC_URL = 'http://dev.example.com/static/'
当我转到我的服务器并尝试上传图像时,我收到此错误:
SuspiciousOperation at /admin/blog/post/add/
Attempted access to '/home/myself/wrong/path/appname/blogImages/Portal2-Logo.jpg' denied.
我试图找出错误的路径可能来自哪里。我还应该在哪里寻找错误的路径?