[Answered ]-How do I test a Django model with ImageSpecField?

2👍

The solution, which worked for me:

from django.core.files.uploadedfile import SimpleUploadedFile

test_room.image = SimpleUploadedFile(name='foo.gif', content=b'GIF87a\x01\x00\x01\x00\x80\x01\x00\x00\x00\x00ccc\x00\x00\x00\x00\x01\x00\x01\x00\x00\x02\x02D\x01\x00')
test_room.save

Leave a comment