Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

APIRequestFactory() returns a WSGIRequest #9654

Unanswered
paulwispnext asked this question in Potential Issue
Discussion options

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.

You must be logged in to vote

Replies: 0 comments

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
1 participant

AltStyle によって変換されたページ (->オリジナル) /