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

response status override using self.status #119

Closed
wants to merge 1 commit into from
Closed

response status override using self.status #119

wants to merge 1 commit into from

Conversation

yuriescl
Copy link

Resource.status is currently being set but not used:
https://github.com/toastdriven/restless/blob/2.1.1/restless/resources.py#L82

An idea is to use it for overriding a successful response status, no matter the endpoint/method.
Example:

def update(self, pk):
    try:
        Post = Post.objects.get(id=pk)
        self.status = 200
    except Post.DoesNotExist:
        self.status = 201
        post = Post()
    
    post.title = self.data['title']
    post.user = User.objects.get(username=self.data['author'])
    post.content = self.data['body']
    post.save()
    return post

Fixes #118
If this gets accepted, please add it to documentation.

@yuriescl
Copy link
Author

Nevermind this, closing.

@yuriescl yuriescl closed this Feb 26, 2020
@yuriescl yuriescl deleted the status branch February 26, 2020 12:05
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.

Allow response status override
1 participant