Skip to content

Commit

Permalink
Maybe fix crash during testing?
Browse files Browse the repository at this point in the history
  • Loading branch information
Adrian-at-CrimsonAuzre committed Mar 12, 2020
1 parent a202802 commit 25f49e5
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions djfractions/models/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit 25f49e5

Please sign in to comment.