[Answered ]-Is it ever necessary to instantiate new HttpRequest objects in Django?

2👍

You should use redirect method

if user is not None:
    return redirect(reverse('index'))

0👍

From the excellent “What technical details should a programmer of a web application consider before making the site public?”,

Redirect after a POST if that POST was successful, to prevent a refresh from submitting again.

So you’re right, you’ll want to redirect to make sure that the previous form isn’t submitted. but further from that, you shouldn’t think about views as being directly linkable and instead get into the mindset that a view is what you get to from making a request. So as afilardo suggests, you should redirect.

return redirect('index')
👤Sayse

Leave a comment