[Django] #32530: readonly makes field return None on cleaned_data?

23 views
Skip to first unread message

Django

unread,
Mar 9, 2021, 5:21:52 AM3/9/21
to django-...@googlegroups.com
#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.

Django

unread,
Mar 9, 2021, 5:58:49 AM3/9/21
to django-...@googlegroups.com
#32530: readonly makes field return None on cleaned_data?
-----------------------------+--------------------------------------
Reporter: rickyManalo | Owner: nobody
Type: Bug | Status: closed
Component: Forms | Version: 3.1
Severity: Normal | Resolution: duplicate

Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-----------------------------+--------------------------------------
Changes (by Mariusz Felisiak):

* status: new => closed
* resolution: => duplicate


Comment:

Duplicate of #30373, see
[https://code.djangoproject.com/ticket/30373#comment:1 comment].

--
Ticket URL: <https://code.djangoproject.com/ticket/32530#comment:1>

Reply all
Reply to author
Forward
0 new messages