1π
β
Do I need to call
super(MyForm, self).clean()
inside βcleanβ method of forms.py explicitly, or will it be called automatically once I do
You need to call it explicitly. That is the method which populates the self.errors
attribute, when some error is found. Using self.errors
youβre just accessing that attribute, not calling any method.
For your second question, it shows KeyError
while accessing self.cleaned_data['data']
(in case when you call super clean method), because when a particular key is added to self.errors
, it is not added to self.cleaned_data
. You need to check the key existence or self.errors
first, before accessing any cleaned_data
key.
π€Rohit Jain
Source:stackexchange.com