If I do upload_to=os.sep, I get an error:
Attempted access to '/test.pdf' denied.
It's trying to upload to the root of the drive!
settings.DOCUMENT_STORE_PATH is something like /var/www/testproject/
documents
file =
models.FileField(storage=FileSystemStorage(location=settings.DOCUMENT_STORE_PATH),
upload_to=os.sep, help_text=_(u"""The file itself."""))
Shouldn't it append the location and the upload_to paths to get the
target destination?
On Sep 9, 9:29 am, Preston Holmes <
pres...@ptone.com> wrote:
> On Sep 8, 5:04 am, Dave <
kru...@seznam.cz> wrote:
>
>
>
>
>
> > Hi everyone,
>
> > I've found in documentation usage of custom file storage. There it is
> > like that (
http://docs.djangoproject.com/en/1.2/topics/files/#the-built-in-files...
> > ) -
>
> > from django.db import models
> > from django.core.files.storage import FileSystemStorage
>
> > fs = FileSystemStorage(location='/media/photos')
>
> > class Car(models.Model):
> > ...
> > photo = models.ImageField(storage=fs)
>
> > Notice there is noupload_toattribute in ImageField. I suppose, it's
> > quite obvious, because I will set it by attribute location in
> > initializing FileSystemStorage object fs. But if I'll do it this way
> > it'll rise an error - Error: One or more models did not validate:
> > app.mymodel: "image": FileFields require an "upload_to" attribute.
>
> > What am I missing? Or is it possiblle to haveupload_tosomehow set to
> > an empty string? So the location would be the same as it is declared
> > in the file storage object initialization.
>
> You've basically answered your question - if you read the docs for
> FileField you will seeupload_tois a required field. It defines path