[Answered ]-Django View – Do an HTTP POST, but do not generate a new page

2👍

The correct way to respond after HTTP POST is to do a redirect. In this case, you could return a HttpResponseRedirect to the page’s url:

from django.http import HttpResponseRedirect
...
def post(self, request):
     ...
     return HttpResponseRedirect(url_to_the_page)

You can use reverse to avoid hardcoding the url and messages to show a flash message after the post.

Leave a comment