models: Update DateField to use Django 1.10 method.

This commit is contained in:
Brett Smith 2017-11-30 11:47:29 -05:00
parent a82ebfb0a9
commit 271f7a8c5b

View file

@ -54,12 +54,11 @@ class Date(datetime.date):
return self.adjust_month(1, day=1) return self.adjust_month(1, day=1)
class DateField(models.DateField, metaclass=models.SubfieldBase): class DateField(models.DateField):
def to_python(self, value): def from_db_value(self, value, expression, connection, context):
retval = super().to_python(value) if value is not None:
if retval is not None: value = Date.from_pydate(value)
retval = Date.from_pydate(retval) return value
return retval
class Payment(models.Model): class Payment(models.Model):