Revised the make_form_from_model() method in the FormView in the Mia core application.

This commit is contained in:
依瑪貓 2020-08-13 22:31:27 +08:00
parent 5a91e85c8e
commit 7d364da930

View File

@ -146,7 +146,8 @@ class FormView(View):
def make_form_from_model(self, obj: Model) -> forms.Form: def make_form_from_model(self, obj: Model) -> forms.Form:
"""Creates and returns the form from a data model.""" """Creates and returns the form from a data model."""
return self._form(obj) return self._form({x: getattr(obj, x, None)
for x in self._form.base_fields})
def fill_model_from_form(self, obj: Model, form: forms.Form) -> None: def fill_model_from_form(self, obj: Model, form: forms.Form) -> None:
"""Fills in the data model from the form.""" """Fills in the data model from the form."""