[Fixed]-How to return an empty form in ModelFormMixin

1👍

get_form uses the request data to construct the form as per the docs

If the request is a POST or PUT, the request data (request.POST and request.FILES) will also be provided.

So simply don’t make your post function go back through the get, just have it redirect to your required place or do anything differently to pointing it at the get function.

return redirect('mynamespace:story_detail', story_id=self.object.pk)

You may wish to read this answer for a list of technical details you should consider whilst making your application. In particular,

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

👤Sayse

Leave a comment