How can I return HTTP status code 204 from a Django view

0 votes
I want to return status code 204 No Content from a Django view. It is in response to an automatic POST which updates a database and I just need to indicate the update was successful (without redirecting the client).

There are subclasses of HttpResponse to handle most other codes but not 204.

What is the simplest way to do this?
Aug 17, 2020 in Python by kartik
• 37,520 points
9,634 views

1 answer to this question.

0 votes

Hello,

Try this:

return HttpResponse(status=204)

Hope it works!!

Thank you!

answered Aug 17, 2020 by Niroj
• 82,800 points
It's work well...Thank you
thank you,it's workes

Related Questions In Python

0 votes
1 answer

How can I convert a list of dictionaries from a CSV into a JSON object in Python?

You could try using the AST module. ...READ MORE

answered Apr 17, 2018 in Python by anonymous
3,866 views
0 votes
1 answer

How can I read numbers in Python from a custom file?

Hi, good question. Let us first assume that ...READ MORE

answered Feb 6, 2019 in Python by Nymeria
• 3,560 points
1,510 views
0 votes
0 answers

how can i read from a stdin?

can you give an example? READ MORE

Apr 1, 2019 in Python by Waseem
• 4,540 points
938 views
0 votes
0 answers