djangoformsdjango-forms

what will happend if a user submits the old form without refreshing the page after I've made changes to the Django form


I have made some changes to the form of my Django website, for example: some values of thoes checkbox were changed.

A user already opened the form before my changes, and he submited the form after making some changes. What will happened?

In my local machine with Django 2.2 and Chrome 116.0.5845.110, the form page was refreshed after I clicked the Save button.

Thanks!

You can ignore the bellowing cause it could be related with my codes.

(The refreshed form is not expected, which contains the new changes but a little different. If I open the url of the form page to a new tab, everything works fine)


Solution

  • A user already opened the form before my changes, and he submited the form after making some changes. What will happened?

    That depends on whether the data of the old form is "compatible" with the new form. In that case, it will be processed, otherwise if you made a proper view that validates the form and then rerenders it, it will render the template again, and now with the new form.

    The data is compatible if all required fields of the new form are filled in in the old form, so with the same name=".." item. For items in the old form that do not map on an element of the new form, these will be ignored, for items in the new form that map not on items on the old form, but are not required, blank values will be filled in, or checkboxes will be seen as False.