#35746: make the form.cleaned_data attribute of form available in the __init__
-------------------------------------+-------------------------------------
Reporter: piscvau | Owner: (none)
Type: | Status: closed
Cleanup/optimization |
Component: Forms | Version: 5.0
Severity: Normal | Resolution: needsinfo
Keywords: clean_field_name , | Triage Stage:
form.full_clean | Unreviewed
Has patch: 1 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Sarah Boyce):
* resolution: => needsinfo
* status: new => closed
Comment:
I think what you're trying to say is that you need to reference
`self.cleaned_data` in `clean_<fieldname>()`
As per the docs, this should be possible:
https://docs.djangoproject.com/en/5.1/ref/forms/validation/#form-and-
field-validation
> The `clean_<fieldname>()` method is called on a form subclass – where
`<fieldname>` is replaced with the name of the form field attribute. This
method does any cleaning that is specific to that particular attribute,
unrelated to the type of field that it is. This method is not passed any
parameters. You will need to look up the value of the field in
`self.cleaned_data` and remember that it will be a Python object at this
point, not the original string submitted in the form (it will be in
`cleaned_data` because the general field `clean()` method, above, has
already cleaned the data once).
Feel free to write a test/share some code if you think you've found a bug
here
--
Ticket URL: <
https://code.djangoproject.com/ticket/35746#comment:2>