I'm trying to save a PDF
into a folder in my project
the folder
has the permissions read, write
when I try to save the PDF
I get this error:
SuspiciousOperation: Attempted access to /opt/django_apps/inscripcion/solicitudes/filename
and this is my simple code:
contenido = "Simple code"
file_name = "/opt/django_apps/inscripcion/solicitudes/filename"
path = default_storage.save(file_name, ContentFile(contenido))
I'm using python2.7
with mod_python
and django1.3
on RedHat
The actual exception is raised in django/utils/_os.py
on line 76:
raise ValueError('The joined path (%s) is located outside of the base '
'path component (%s)' % (final_path, base_path))
And base_path
for default_storage
is settings.MEDIA_ROOT
.
I'd suggest creating FileSystemStorage
with
file_storage = FileSystemStorage(location = '/opt/django_apps/inscripcion/solicitudes/')
And then
contenido = "Simple code"
file_name = "filename"
path = file_storage.save(file_name, ContentFile(contenido))