from django.http import Http404
from django.shortcuts import get_object_or_404
+from django.http.request import QueryDict
from rest_framework.exceptions import PermissionDenied
from rest_framework.generics import ListCreateAPIView
from rest_framework.generics import RetrieveAPIView
if label != data['state']:
continue
- if isinstance(data, dict): # json request
- data['state'] = val
- else: # form-data request
+ if isinstance(data, QueryDict): # form-data request
# NOTE(stephenfin): 'data' is essentially 'request.POST', which
# is immutable by default. However, there's no good reason for
# this to be this way [1], so temporarily unset that mutability
data._mutable = True # noqa
data['state'] = val
data._mutable = mutable # noqa
+ else: # json request
+ data['state'] = val
break
return super(CheckSerializer, self).run_validation(data)