summaryrefslogtreecommitdiff
path: root/postgresqleu/util/backendviews.py
diff options
context:
space:
mode:
authorMagnus Hagander2023-06-12 21:05:00 +0000
committerMagnus Hagander2023-06-14 09:03:03 +0000
commit6d4c671a8feb5ad905e5f2a29ae1b5dbf8d29211 (patch)
tree40b9fc1f4071a6664d9de5522acc70adda20235d /postgresqleu/util/backendviews.py
parent9bc9ca5861567eb166fb424df8afa0b71133967e (diff)
Allow custom submit buttons to return a HttpResponse
And if they do, return this immediately instead of continuing to process the submit.
Diffstat (limited to 'postgresqleu/util/backendviews.py')
-rw-r--r--postgresqleu/util/backendviews.py7
1 files changed, 6 insertions, 1 deletions
diff --git a/postgresqleu/util/backendviews.py b/postgresqleu/util/backendviews.py
index aa9ec34b..e1eb614b 100644
--- a/postgresqleu/util/backendviews.py
+++ b/postgresqleu/util/backendviews.py
@@ -152,7 +152,12 @@ def backend_process_form(request, urlname, formclass, id, cancel_url='../', save
# We do!
f = form.fields[k[10:]]
if f.callback:
- f.callback(request)
+ r = f.callback(request)
+ # If the callback returns a HttpResponse
+ # (typically a redirect), return that immediately
+ # (without saving the form).
+ if isinstance(r, HttpResponse):
+ return r
return HttpResponseRedirect(".")
if form.is_valid():