[Answer]-How to grab data from fields in the model and populate them to a django form

1👍

I believe it is because of this line; LayoutUpdateForm = LayoutForm(MyLayout). The first argument to a Django Form is data, but you want to use the instance arguments [1]. Try changing it to LayoutUpdateForm = LayoutForm(instance=MyLayout).

NOTE: This assumes your LayoutForm is inherited from forms.ModelForm.

[1] https://github.com/django/django/blob/master/django/forms/models.py#L313

👤vishen

Leave a comment