ModelChoiceField.clean call to_python and validate from ChoiceField
Reported by: |
Petr Marhoun <petr.marhoun@…> |
Owned by: |
nobody |
Component:
|
Forms
|
Version:
|
dev
|
Severity:
|
|
Keywords:
|
|
Cc:
|
|
Triage Stage:
|
Accepted
|
Has patch:
|
yes
|
Needs documentation:
|
no
|
Needs tests:
|
no
|
Patch needs improvement:
|
no
|
Easy pickings:
|
no
|
UI/UX:
|
no
|
Comment in ModelChoiceField says: This class is a subclass of ChoiceField for purity, but it doesn't actually use any of ChoiceField's implementation.
But with model level validation method ModelChoiceField.clean calls Field.clean and it calls self.to_python and self.validate, in reality ChoiceField.to_python and ChoiceField.validate. And for ModelChoiceField these methods are useless and can be harmful - for example (my problem) with hidden ModelChoiceField choices were not created but they are now, it could be very ineffective.
Thanks, could you provide some tests for this behavior?