DRF The submitted data was not a file. Check the encoding type on the form - ImageField
<p>I have the following model <code>User</code> serializer:</p>

<p>The <code>team</code> field is a <code>ForeignKey</code> in the <code>User</code> model and it's serialized for optimize their query in performance with the <code>setup_eager_loading</code> function</p>

<pre><code>class UserSerializer(serializers.ModelSerializer):
    team = serializers.StringRelatedField()

    def setup_eager_loading(queryset):
      queryset = queryset.select_related('team',)

    class Meta:
        model = User
        fields = ('url', 'username','password','first_name','last_name',
        'photo','team','position','last_login',)
</code></pre>

<p>My <code>viewset</code> to <code>User</code> is the folowing:</p>

<pre><code>from rest_framework import viewsets
from rest_framework import filters

from .models import User
from .serializers import UserSerializer



# Viewsets define the behavior of the view
class UserViewSet(viewsets.ModelViewSet):
    """
    API endpoint that allows users to be viewed or edited.
    """
    queryset = User.objects.all().order_by('-date_joined')
    serializer_class = UserSerializer
    filter_fields = ('username','is_player', 'first_name','last_name','team','email',)
</code></pre>

<p>When I go to an user instance in my api serializers and I want update via <code>raw data media type: application/json</code>, I get the following message:</p>

<p><a href="https://i.stack.imgur.com/3Z8md.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Z8md.png" alt="enter image description here"></a></p>

<p>In my <code>User</code> model the image field is defined of this way:</p>

<pre><code>class User(AbstractBaseUser, PermissionsMixin):
#... other attributes  
    photo = models.ImageField(upload_to='avatars', blank=True)
</code></pre>

<p>How to can I update any field/attribute in my User serialized model via JSON raw data without appear this message about of encoding type in the <code>photo</code> field</p>

<p>In <a href="https://stackoverflow.com/a/28036805/2773461">this question</a> talk about of base64 encoded string in relation to DRF expected in the update request, but I try adding the <code>Base64ImageField</code> serializer and using it in my <code>UserSerializer</code> class but I get this:</p>

<p><a href="https://i.stack.imgur.com/eTDde.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eTDde.png" alt="enter image description here"></a></p>

<p>with the exception:</p>

<pre><code>Exception Value: Incorrect padding
</code></pre>