python - Coerce in django forms -


what coerce argument in django forms? i've read documentation, not helpful, explanation few examples of use cases helpful. quote documentation:

a function takes 1 argument , returns coerced value. examples include built-in int, float, bool , other types. defaults identity function.

typedchoicefield choicefield, except choicefield return unicode.

with typedchoicefield pass function takes 1 argument , returns value cast type want. example, if want coerce value integer, use:

int_field = forms.typedchoicefield(choices=some_choices, coerce=int) 

the field value integer or fail validation.


Comments

Popular posts from this blog

ios - UICollectionView Self Sizing Cells with Auto Layout -

node.js - ldapjs - write after end error -

DOM Manipulation in Wordpress (and elsewhere) using php -