Opened 2 months ago
Last modified 2 months ago
#35746 closed Cleanup/optimization
make the form.cleaned_data attribute of form available in the __init__ — at Initial Version
Reported by: | piscvau | Owned by: | |
---|---|---|---|
Component: | Forms | Version: | 5.0 |
Severity: | Normal | Keywords: | clean_field_name, form.full_clean |
Cc: | Triage Stage: | Unreviewed | |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Hello
form.clean_field_name functions have no parameter passed to it as indicated in the documentation and need to access the form.cleaned_data dictionnary. However this cleaned_data dictionnary is not created in the init of the form but only in the full_clean method of the form.
the need:
in the form.init, add closure functions as clean_field_name functions and use the cleaned_data dictionnary as a free variable of this closure function. However this is not possible because the cleaned_data_dictionnary is not yet created.
Suggested patch :
create the cleaned_data.attribute in the init instead of the full_clean