Django Rest Framework, Testing ImageField

I start developing a web API with Django rest framework lately. So It was a little bit challenging for me to write the test for ImageField because I am not so familiar with Django environment.

So I just publish how I got over the problem. Maybe it helps someone out there.

In my case, It was a simple category app with photo field. All we need to do is populate the field with an image file but the trick is that the request format must be ‘multipart‘.

 

Leave a Reply

Your email address will not be published. Required fields are marked *