Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update JSONRenderer to render a null response when data=None #6027

Closed
wants to merge 3 commits into from

Conversation

kltdwrds
Copy link

Description

Fixes #6026

Render a null response when `data=None`
Copy link
Member

@rpkilby rpkilby left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A test to verify the behavior would be required for acceptance.

@kltdwrds
Copy link
Author

@rpkilby updated to fix the failures and add additional coverage

@novarac23
Copy link

+1

@rpkilby
Copy link
Member

rpkilby commented Jun 14, 2018

I'm wondering if it's more appropriate for the response object to handle 204/304 empty content. i.e., this behavior is universal across all content types, not just application/json.

@MattBlack85
Copy link

MattBlack85 commented Jun 14, 2018

correct me if I'm wrong but there is no obligation to return some content on any status code, if this is going through how am I supposed to return an empty content for status codes other than 204? While for this case is enough to pass {} when returning a response to get rid of the error on ajax?

from jsonapi spec:
A JSON object MUST be at the root of every JSON API request and response *containing data*

@tomchristie
Copy link
Member

Closing as per #6026.
This is one of those cases where there two different sets of behavior that could equally well be desired. I'd rather we leave the behavior as it currently is, and have return Response() indicate that an empty response should be returned with no content or content-type set.

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

Successfully merging this pull request may close these issues.

None yet

5 participants