From 8516de8f612f243631d84b65ba113ca48d8b7e20 Mon Sep 17 00:00:00 2001 From: Adrian Turjak Date: Fri, 12 Apr 2019 20:24:46 +1200 Subject: [PATCH] Correctly set content-type for workflow response The default content-type is html, and under certain circumstances like devstack the html has some additional comments added. Because this specific content is meant to be parsed as json those extra html comments break the modal.js code. We can't set the content-type to json without rewriting parts of modal.js, as it will will parse it into an object early and then modal.js will fail as it attempts to parse an object into json. Change-Id: If5a9ee7fe4273dc368dec7767a55d4467bf6a1a7 Closes-bug: #1824484 --- horizon/forms/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/horizon/forms/views.py b/horizon/forms/views.py index 294226a51b..59f84295dd 100644 --- a/horizon/forms/views.py +++ b/horizon/forms/views.py @@ -192,7 +192,8 @@ class ModalFormView(ModalFormMixin, views.HorizonFormView): field_id = self.request.META[ADD_TO_FIELD_HEADER] data = [self.get_object_id(handled), self.get_object_display(handled)] - response = http.HttpResponse(json.dumps(data)) + response = http.HttpResponse( + json.dumps(data), content_type="text/plain") response["X-Horizon-Add-To-Field"] = field_id elif isinstance(handled, http.HttpResponse): return handled