1

我正在尝试将 a 保存到我的PDF文件夹中,当我尝试保存时,我收到此错误:projectfolderread, writePDF

SuspiciousOperation:试图访问 /opt/django_apps/inscripcion/solicitudes/filename

这是我的简单代码:

 contenido = "Simple code"
 file_name = "/opt/django_apps/inscripcion/solicitudes/filename"
 path = default_storage.save(file_name, ContentFile(contenido))

我正在使用python2.7withmod_pythondjango1.3onRedHat

4

1 回答 1

2

实际的异常django/utils/_os.py在第 76 行提出:

raise ValueError('The joined path (%s) is located outside of the base '
                 'path component (%s)' % (final_path, base_path))

base_path对于default_storagesettings.MEDIA_ROOT

我建议FileSystemStorage

file_storage = FileSystemStorage(location = '/opt/django_apps/inscripcion/solicitudes/')

接着

contenido = "Simple code"
file_name = "filename"
path = file_storage.save(file_name, ContentFile(contenido))
于 2013-07-24T22:14:47.683 回答