[Fixed]-Django text in SmallIntegerField results in a KeyError

1๐Ÿ‘

โœ…

If you enter non-valid values into a field, that field is by definition not clean, so it will not be present in cleaned_data; hence the KeyError.

Unless you need this value to do some validation in combination with another field, you should do whatever you are doing in the specific clean_height method; this will only be called if the value passes the built-in field validation.

๐Ÿ‘คDaniel Roseman

Leave a comment