Hi Christoph,
since the FileField refactoring you can define a callable for upload_to.
Basically that's a function which knows about the instance and filename and
returns the full image path. Like this:
from django.conf import settings
def get_img_storage_path(instance, filename):
return '%salbums/images/%s/' % (settings.MEDIA_ROOT, instance.album.pk)
class Photo(models.Model):
img = models.FileField(upload_to=get_img_storage_path, blank=True)
Also see:
http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.FileField.upload_to
Best Regards,
Dirk Eschler
--
Dirk Eschler <dirk.e...@gmx.net>
http://www.krusader.org
Forgot the filename in my example...
def get_img_storage_path(instance, filename):
return '%salbums/images/%s/%s' % (settings.MEDIA_ROOT, instance.album.pk,
filename)