-
-
Notifications
You must be signed in to change notification settings - Fork 7k
APIRequestFactory() returns a WSGIRequest #9654
Unanswered
paulwispnext
asked this question in
Potential Issue
-
Well as per title, APIRequestFactory() returns a WSGI request object. This means that it doesn't have a .data
attribute.
The quick solution that google shows is to wrap it in a Request
object. However if we do something like:
factory = APIRequestFactory()
request = factory.post('', {'title': 'new idea'}) # no path is relevant, we do not use it in our tests, just the data.
drf_request = Request(request)
print(drf_request.data)
We get the following error:
raise exceptions.UnsupportedMediaType(media_type)
And debugging shows that the parsers (list) is empty.
Beta Was this translation helpful? Give feedback.
All reactions
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment