Django comefrom considered harmful
Forms in Django have a feature which is essentially comefrom. It might not be obvious until you have gotten bitten a few times though. Let’s take a very simple example:
class MyForm(forms.Form): foo = forms.CharField() def clean_foo(self): if self.cleaned_data['foo'] == 'bar': raise forms.ValidationError('bar is an invalid value')
Just because the name of the method matches the pattern clean_
This was one of many reasons we ended up writing a replacement form library. Look at the same example in tri.form:
class MyForm(Form): foo = Field.text(is_valid=lambda value, **_: (value != 'bar', "bar is an invalid value"))
The risk of breaking things by having your stringly typed stuff not line up is gone (and we get rid of a lot of boilerplate as a bonus).