From 271f7a8c5b9cb0cedc32fff0eec44e92f9f6ee18 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Thu, 30 Nov 2017 11:47:29 -0500 Subject: [PATCH 1/2] models: Update DateField to use Django 1.10 method. --- python/supporters/models.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) 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): From 5b43b6d3f37a9ba0fd73ceeb130059d990060b82 Mon Sep 17 00:00:00 2001 From: Brett Smith Date: Thu, 30 Nov 2017 11:47:54 -0500 Subject: [PATCH 2/2] README: Update database migration method for Django 1.10. --- python/README.rst | 1 + 1 file changed, 1 insertion(+) 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::