tags:

views:

200

answers:

1

It seems that if I do not create a ModelForm from a model, and create a new object and save it, it will not respect the field's upload directory.

How do I change the directory of a InMemoryUploadedFile so I can manually implement the upload dir? Because the InMemoryUploadedFile obj is just the filename, and I would like to add the upload dir parameters. Thank you!

def add_image(self, image):
    pi = ProductImages()
    pi.image = image
    pi.save()
    self.o_gallery_images.add(pi)
    return True

(Code that does not respect the upload dir of ProductImages "image" field)

A: 

How did you define the attribute of image in your ProductImages model? Did you have upload_to argument in your FileField?

class ProductImages(models.Model):
    image = models.FileField(upload_to="images/")
jpartogi