lundi 2 juin 2014

Flask: Getting 400 Bad request on form with bootstrap button groups


Vote count:

0




I'm using Flask and bootstrap for developing a small web application. For the settings page of this application, I read configuration values from a sqlite database and draw controls on page according to these values, all included in an html form so when I change settings and submit the form, I can POST the request with all the values written back to the database.

When rendering the page, all the settings are correctly drawn. E.g., on a three radio button group (drawn with bootstrap as a nice set of buttons), the proper value gets selected.

However, when submitting the form with POST, I'm getting a 400 Bad request because the settings that have not been changed from the original values loaded are not passed to the POST request. However, if I click in the already selected setting (nothing changes because the radio buttons already had those values), then the field is correctly included in the request.

I know that I can workaround this by checking which fields are present in the POST request (i.e. which keys for the args dict are present), but being imbued with the pythonic spirit, I consider that the pure HTML form posting should include all the fields defined within the form, so no further controls should be necessary when processing the request. The question is, why the form fields that have been left untouched in the page since its rendering are not included in the request? Is there a way to force the inclusion of these values or am I missing something?

Many thanks in advance



asked 44 secs ago






Aucun commentaire:

Enregistrer un commentaire