#32530: readonly makes field return None on cleaned_data?
---------------------------------------+------------------------
Reporter: rickyManalo | Owner: nobody
Type: Bug | Status: new
Component: Forms | Version: 3.1
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
---------------------------------------+------------------------
On my Form's clean(), I'm getting the values of some fields from their
cleaned_data and check if they are empty and throw a ValidationError when
they are. When certain conditions are met, all the fields would be
readonly when editing. Initial saving works fine. But when I try to resave
a Form which the fields I needed to check are readonly, somehow it creates
a ValueError: 'Form' has no field named 'field_name', making me think that
when a field is readonly, it's value isn't being set on it's cleaned_data
or the Form "forgets" it's model's fields.
{{{
def clean(self):
start_date = self.cleaned_data.get('start_date')
end_date = self.cleaned_data.get('end_date')
if start_date is None:
raise forms.ValidationError({'start_date': ["Start date is
empty",]})
elif end_date is None:
raise forms.ValidationError({'end_date': ["End date is
empty",]})
}}}
The ValueError is thrown by the if start_date is None: line
--
Ticket URL: <https://code.djangoproject.com/ticket/32530>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/054.05e6a4fcc3c167e645ef2837fb739134%40djangoproject.com.