TypedChoiceField and TypedMultipleChoiceField call the super validate() method instead of their own
|Reported by:||Berislav Lopac||Owned by:||Berislav Lopac|
|Has patch:||yes||Needs documentation:||no|
|Needs tests:||yes||Patch needs improvement:||no|
As it can be seen on https://github.com/django/django/blob/master/django/forms/fields.py#L730, instead of calling self.validate() the code is actually super(TypedChoiceField, self).validate(value); it's the same on https://github.com/django/django/blob/master/django/forms/fields.py#L780
On the other hand, the definition of the validate() methods in both classes is a simple "pass".
I believe this is a bug because it makes it impossible to extend those classes and customize the validate() method. Specifically, in this example the validate() is never called:
class CustomTypedMultipleChoiceField(forms.TypedMultipleChoiceField): def validate(self, value): print("CustomTypedMultipleChoiceField.validate")
I propose that, instead of the current situation, lines 730 and 780 are replaced with self.validate(), and the validate() method definitions are either removed or changed to call the super.
Change History (10)
comment:1 Changed 4 years ago by
|Patch needs improvement:||unset|
|Triage Stage:||Unreviewed → Accepted|
comment:2 Changed 4 years ago by
|Owner:||changed from nobody to Berislav Lopac|
|Status:||new → assigned|