On Wednesday, January 12, 2011 6:11:27 AM UTC, nlub...@gmail.com wrote: > > hello, i have a very simple question. its about imagefiles > > my model > class Usuario(models.Model): > ImagenEmpresa = models.ImageField(upload_to = 'perfil/', > null=True) > > my template > <form id="form2" name="form2" method="post" action="" > enctype="multipart/form-data" onSubmit="return check(this);"> > <input type="file" name="ImagenEmpresa" id="ImagenEmpresa" /> > </form> > and my save method > nuevo = Usuario(ImagenEmpresa = > request.FILES['ImagenEmpresa']) > nuevo.save() > > this save the image im uploading to the file folder correctly but i > want to change the name of the image > example. > > if im uploading a "testofimage.gif" > i would like to save it as "Profileoduser.gif"
upload_to can be a callable, ie a function that handles the uploaded file. This is passed the image file and original filename, and should return the absolute path. See the documentation: http://docs.djangoproject.com/en/1.2/ref/models/fields/#django.db.models.FileField.upload_to So you could use that to rename the file appropriately. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@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.