worked like a charm.  thx.

On Sep 18, 5:21 pm, gnijholt <[EMAIL PROTECTED]> wrote:
> I had to define the callable function before it gets called.
> So in your case I'd put it right under class Product(models.model)
> Then you should be able to just do:
>   upload_to=get_image_path
>
> Cheers,
>
> On Sep 18, 10:20 pm, lingrlongr <[EMAIL PROTECTED]> wrote:
>
> > According to the documentation, I can make the upload_to argument a
> > callable (which must receive 2 args):
>
> > class Product(models.Model):
> >     number = models.CharField(max_length=20)
> >     image = models.ImageField(upload_to='<callable>')
>
> > I want to build a path so it looks like this (with respect to
> > MEDIA_URL):
> >   images/products/<number>/<original_file_name>
>
> > def get_image_path(instance, filename):
> >   return 'images/products/%s/%s' % (instance.number, filename)
>
> > I tried:
> >   upload_to='get_image_path'
> >   upload_to=get_image_path
> >   upload_to=get_image_path()
> >   upload_to=self.get_image_path
>
> > How can I accomplish that?
--~--~---------~--~----~------------~-------~--~----~
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 [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to