From b62f500b2e8d7e79ed62443ae3c7949a1969b8a7 Mon Sep 17 00:00:00 2001 From: Francesco Siddi Date: Thu, 4 Apr 2019 13:09:53 +0200 Subject: [PATCH] Cast empty string value in form_field to None For FilmProjectForm, when no value is specified we want to save it as None in the project document. --- cloud/routes.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/cloud/routes.py b/cloud/routes.py index 5818721..2516f45 100644 --- a/cloud/routes.py +++ b/cloud/routes.py @@ -608,6 +608,9 @@ def save_film_settings(project: pillarsdk.Project): form_field = getattr(form, field_name) # TODO(fsiddi) if form_field type is FileSelectField, convert it to ObjectId # Currently this raises TypeError: Object of type 'ObjectId' is not JSON serializable + + if form_field.data == '': + form_field.data = None updated_extension_props[field_name] = form_field.data # Update extension props and save project