I solved this another way, today. I move the file to it's new filename
in the save method of the model. It's not fully tested but seems to
work. In my case I use a slug field to create nice filenames.

    def save(self):
        if self.image:
            import shutil
            from os import path
            from django.conf import settings
            pathname, filename = path.split(self.image)
            extension = path.splitext(filename)[1]
            new_image = path.join(pathname, '%s%s' % (self.slug,
extension))
            new_location = path.join(settings.MEDIA_ROOT, new_image)
            old_location = path.join(settings.MEDIA_ROOT, self.image)
            if new_location != old_location:
                shutil.move(old_location, new_location)
                self.image = new_image
                
        super(Image, self).save()

Rudolph


--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to