J
J
JRazor2015-10-05 13:01:42
MongoDB
JRazor, 2015-10-05 13:01:42

WTForms: what and how should the Form class return?

Dear colleagues.

The problem is this: in WTForms I use the FormField(Birthday) field . The Birthday class has three fields: day, month, and year. I want the user to be able to select a date from choices. In the model itself, birthday is a field datatimeField .

But when using form.populate_obj(user) , which saves fields of the same name to the database from the form, I get a completely logical error - "The date format is not writable". That is, it cannot write birthday.day , birthday.month and birthday.year .

Lo0TLmI.png

What function to use to combine the data inside the class and send it to the FormField??? Or is there another way to solve this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
B
Bteam, 2015-10-15
@Bteam

I don't know exactly how it's done in WTForms, but in Django it's done a little differently.
There are composite widgets, that is, there is one field, and it is rendered into two or more inputs.
Validation produces only one value.
I found a similar moment in WTForms wtforms.simplecodes.com/docs/0.6.1/fields.html#fie...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question