[Django]-Django – Can a POST and GET request be returned in one HttpRequest?

6πŸ‘

You don’t return a request but a response. The response do not care if its for GET or POST, it depends upon your implementation as to what you want to do and respond for those requests.

EDIT for comment:
You can safely use your method of checking type of request, i.e. using request.method == 'POST' or request.method == 'GET. If you want to double sure check for request.POST as well.
e.g.

if request.method == 'POST' and request.POST:
    #do POST processing

elif request.method == "GET" and request.GET :
    #do GET processing
πŸ‘€Rohan

1πŸ‘

Turns out that one HTTP response (as in the underlying technology) cannot / should not return both POST and GET data. I think this fundamental misunderstanding on my part confused people.

πŸ‘€jhoyla

Leave a comment