|
|
@@ -234,6 +234,8 @@ class ObjectEditView(GetReturnURLMixin, BaseObjectView):
|
|
|
# If this is an HTMX request, return only the rendered form HTML
|
|
|
if htmx_partial(request):
|
|
|
return render(request, self.htmx_template_name, {
|
|
|
+ 'model': model,
|
|
|
+ 'object': obj,
|
|
|
'form': form,
|
|
|
})
|
|
|
|
|
|
@@ -288,6 +290,7 @@ class ObjectEditView(GetReturnURLMixin, BaseObjectView):
|
|
|
msg = f'{msg} {obj}'
|
|
|
messages.success(request, msg)
|
|
|
|
|
|
+ # If adding another object, redirect back to the edit form
|
|
|
if '_addanother' in request.POST:
|
|
|
redirect_url = request.path
|
|
|
|
|
|
@@ -303,6 +306,12 @@ class ObjectEditView(GetReturnURLMixin, BaseObjectView):
|
|
|
|
|
|
return_url = self.get_return_url(request, obj)
|
|
|
|
|
|
+ # If the object has been created or edited via HTMX, return an HTMX redirect to the object view
|
|
|
+ if request.htmx:
|
|
|
+ return HttpResponse(headers={
|
|
|
+ 'HX-Location': return_url,
|
|
|
+ })
|
|
|
+
|
|
|
return redirect(return_url)
|
|
|
|
|
|
except (AbortRequest, PermissionsViolation) as e:
|