Hi,
I want to upload photos to directories structured by the album primary
key. I have the following model:

class Photo(models.Model):
    album = models.ForeignKey(Album)
    img = models.FileField(upload_to='albums/images/' + str(album.pk)
+ '/',  blank=True)

The str(album.pk) part is not working. As I understand it I can't use
the album as an object of type album here like in views/templates (I'm
new to python and haven't fully understand the mechanisms working
underneath, but I guess the class declaration is processed earlier,
when the information is not yet available).

Nevertheless, I'm sure I can use the foreign key id for albums somehow
as part of the path, but how?
Any hint will be appreciated.

Thanks,
Christoph
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to