Hi, I used to use a pre 1.0 svn version of Django. There I had this class:

class Foto(models.Model):
    descripcion = models.CharField(max_length=30, blank=True,
verbose_name=u"descripción")
    imagen = models.ImageField(upload_to='imagenes', verbose_name=u"foto")
    inmueble = models.ForeignKey(Inmueble)

    ....

    def _save_FIELD_file(self, field, filename, raw_contents, save=True):
        '''
        Se reescribe el metodo de la clase padre para definir el
nombre de archivo con
        el que se guardará la imagen en el sistema de archivos. Se
utilizan enteros crecientes.
        '''
        if TESTING:
            field.upload_to = 'tests_dest'
        filename = Foto._cambio_de_nombre(filename)
        raw_contents = Foto._ajustar_tamanio(raw_contents)
        super(Foto, self)._save_FIELD_file(field, filename, raw_contents, save)

The  _save_FIELD_file method was redefined to change the file name and
resize it. Now in 1.0 I can rename the filename with a callable to use
as upload_to ImageField argument:

def _upload_to(instance, filename):
    intancia.imagen. raw_contents = Foto._ajustar_tamanio(raw_contents)
    filename = Foto._cambio_de_nombre(filename)
    if TESTING:
        return os.path.join('tests_dest', filename)
    return os.path.join('imagenes', filename)

but I don't know where I have to put my code to resize the image
before it gets saved. Can anyone help me?

Thanks,

Juanjo

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