Django Fractions Has A User!by justin on Jan. 1, 2017, 3:13 a.m. UTC
I got my first bug report for Django Fractions. That's awesome! It means someone uses it and finds it useful enough to report a bug! The bug was that it was not playing nicely at all with forms in the django admin site (or elsewhere using a ModelForm, most likely). I fixed it and learned a bit more about Django's internals.
The base fix was to implement the
formfield() method on djfractions.
models.fields.DecimalFractionField. That in itself took a bit more work than expected and in the end I stopped subclassing the built in DecimalField because there are just too many things which need to be different. Instead the field now just subclasses Field, but still specifies
get_internal_type() based on the recommendations in the comments for
Field.get_db_type() found here.
I have now released v1.0.0 on PyPI with these fixes plus additional test cases for the formfield() method and validation previously provided by DecimalField.