I would like to know if it is possible to stay on the same page without having it reload to a success_url using FormView. Ideally I would it to just send a notification or do nothing at all. just process the form. if this makes sense.
my code currently looks like this in views.py
class Capture(FormView):
template_name = "capture.html"
success_url = '/'
form_class = TestForm
def form_valid(self, form, *args, **kwargs):
print("Submit Capture")
form.save_screenshot()
return super().form_valid(form)
how can I change this to not reload my page. Other libraries or methods are welcomed and not limited to using FormView.
You should always redirect after a successful POST, to avoid any issues with double submissions (if the user presses Refresh, for example). But there's nothing to stop you redirecting back to the same page.