yes, this how you can upload image or whatever file to folder outside
MEDIA..it uploads to PRIVATE_ROOT/<username>...
This is simple version of Image model in my project:
from django.core.files.storage import FileSystemStorage
from contrib.models.fields import CustomFileField
fs = FileSystemStorage(location='%s/profile'%(settings.PRIVATE_ROOT),
base_url='/%s/profile/'%(settings.PRIVATE_URL))
class Image(ImageModel):
profile = models.ForeignKey(UserProfile)
image = CustomFileField(prime_upload=True ,storage=fs)
def get_upload_to(self, field_attname):
try:
return self.profile.user.username
except:
pass
Don't worry abou the CustomFileField, it's just FileField with few my
enhancements. And ImageModel is model from imagekit, but it should
work also with models.Model (don't know for sure, but this works with
Django 1.2.1).
Remember that you should also write functions to display images or
configure your server to display them.
Radovan
On 12. Apr, 14:35 h., Thomas Weholt <[email protected]> wrote:
> I see from the docs that ImageField takes an param called upload_to. I
> want to put uploaded files into a specific folder for that specific
> user uploading the image. And the target folder is NOT in the media
> root. Any tips on how to achieve that?
>
> --
> Mvh/Best regards,
> Thomas Weholthttp://www.weholt.org
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.