Hello everybody,

I sent this to Django users but got no replies, I also think this has
to do with some shortcommings of ImageField.
I want to create a gallery app and I have a slight problem, my
models.py code looks like this:

...
class Gallery(models.Model):
   slug = models.SlugField(...)
   ...

class Image(models.Model):
   ...
   gallery = models.ForeignKey(...)
   image = models.ImageField(
       upload_to=(lambda:'images/%s' % gallery.slug),
       ...,)
...

This won't work, because the ImageField constructor wants "upload_to"
to be a String and no Funtion. The Problem is, I want a dynamic image
storage path,  something like MEDIA_ROOT+"images/" wont work with
hundrets of galleries, I need something like MEDIA_ROOT
+"images/"+gallery.slug . In my Image class "gallery" is a ForeignKey,
which will have the attribute "slug" at runtime, but not at model
creation time, either I am doing something stupid or there is
currently no way to solve this.

As far as I know there is currently also no (django integrated) way of
thumbnailing images, wouldn't it be nice to have this in the model? I
know it is possible to solve this via the save() method and in the
filesystem, but this is rather hacky.

Sascha Peilicke
--
http://saschashideout.de


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

Reply via email to