Skip to content
Snippets Groups Projects
Commit c7f5e630 authored by Julian's avatar Julian
Browse files

Correctly serialize model values

parent e8981c9c
No related branches found
No related tags found
1 merge request!3Draft: Resolve "Create Model for instances of a form"
...@@ -38,7 +38,15 @@ class LayoutNode(ABC): ...@@ -38,7 +38,15 @@ class LayoutNode(ABC):
if isinstance(field, LayoutNode): if isinstance(field, LayoutNode):
model.update(field.build_model(form)) model.update(field.build_model(form))
else: else:
model[field] = str(form[field].value()) # FIXME: Correctly serialize # Convert the value of the form to a JSON-representable type to put inside the html form
# This is done using the BoundField.value(), Field.prepare_value() and Widget.format_value()
# methods, as different django libraries do this formatting at different places.
field_class = form[field].field
model[field] = field_class.widget.format_value(
field_class.prepare_value(
form[field].value()
)
)
return model return model
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment