From 19b0105b77ccee2347c9b119e2f3786f039404a6 Mon Sep 17 00:00:00 2001 From: Adrian-at-CrimsonAuzre Date: Thu, 12 Mar 2020 14:11:54 -0400 Subject: [PATCH] Maybe stops a crash? --- djfractions/models/fields.py | 26 ++++++++++++++++++-------- 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/djfractions/models/fields.py b/djfractions/models/fields.py index 2fcc397..ce8a21f 100644 --- a/djfractions/models/fields.py +++ b/djfractions/models/fields.py @@ -119,14 +119,24 @@ def _check_decimal_places_and_max_digits(self, **kwargs): ] return [] - def from_db_value(self, value, expression, connection, context=None): - if value is None: - return value - - # this probably needs to call to_fraction() - # cann it just call to_python() for now? - #return fractions.Fraction(value) - return self.to_python(value) + if django.VERSION[0] < 3: + def from_db_value(self, value, expression, connection): + if value is None: + return value + + # this probably needs to call to_fraction() + # cann it just call to_python() for now? + #return fractions.Fraction(value) + return self.to_python(value) + else: + def from_db_value(self, value, expression, connection, context): + if value is None: + return value + + # this probably needs to call to_fraction() + # cann it just call to_python() for now? + #return fractions.Fraction(value) + return self.to_python(value) def get_db_prep_save(self, value, connection): # for django 1.9 the following will need used.