diff --git a/python/README.rst b/python/README.rst index 704b95b..a202bb5 100644 --- a/python/README.rst +++ b/python/README.rst @@ -14,6 +14,7 @@ You'll need Python 3, Django, and Ledger:: Create the database:: + $ ./manage.py makemigrations supporters $ ./manage.py migrate Load data from Ledger. Depending on how you've configured Ledger, you may need to tell it where to find the books with Supporter payments. You can pass additional arguments to configure how the import is done; run the script with the ``--help`` flag for details. A typical first import looks like:: diff --git a/python/supporters/models.py b/python/supporters/models.py index cc9e21d..cb76437 100644 --- a/python/supporters/models.py +++ b/python/supporters/models.py @@ -54,12 +54,11 @@ class Date(datetime.date): return self.adjust_month(1, day=1) -class DateField(models.DateField, metaclass=models.SubfieldBase): - def to_python(self, value): - retval = super().to_python(value) - if retval is not None: - retval = Date.from_pydate(retval) - return retval +class DateField(models.DateField): + def from_db_value(self, value, expression, connection, context): + if value is not None: + value = Date.from_pydate(value) + return value class Payment(models.Model):