Wednesday, September 8, 2010

upload_to vs FileSystemStorage

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-filesystem-storage-class
) -

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 no upload_to attribute 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 have upload_to somehow set to
an empty string? So the location would be the same as it is declared
in the file storage object initialization.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate