Using mongoengine with models.ImageField

I am having problems with the django / mongoengine application to use django-athumb . I try to save different sizes of images and store them on S3, which is what the athletes do when used with the installation version of django. However, using mongoengine, calling the save () function in an object field causes the ImageWithThumbsField object to not have a save attribute.

inside the views function, which is associated with loading the file (where doc.image is ImageWithThumbsField):

if request.FILES.get('image'): file = request.FILES['image'] fdat = file.read() file_contents = ContentFile(fdat) doc.image.save(file.name, file_contents) 

the above results lead to the above error.

if I call instead:

 doc.image.attr_class(file_contents, doc.image, file.name).save(file.name, file_contents) 

I can access the save method, but it breaks in and can cause more problems than it solves. My question is: since subclasses of ImageWithThumbsField models.ImageField, is it impossible (or at least impractical) to use models.ImageField with mongoengine?

+4
source share
1 answer

I know this question is old, but it seems that at that time there was no ImageField support in mongoengine - this was added in version 0.6.

If you still have a problem with mongoengine, try upgrading to version 0.6 .. they even throw away the ability to generate a sketch

+1
source

All Articles