class UserSerializer(serializers.ModelSerializer):


    class Meta:
        model = User
fields = 'id', 'username', 'email', 'first_name', 'last_name', 'password'

def restore_object(self, attrs, instance=None):
    attrs['password'] = make_password(attrs['password'])
return super(UserSerializer, self).restore_object(attrs, instance=None)
Django rest change users password view