From 95cc042c60851bc62204bf6a4a2bcd398935fabf Mon Sep 17 00:00:00 2001 From: Guillaume Andreu Sabater Date: Mon, 29 Aug 2016 18:53:06 +0200 Subject: [PATCH] Compatibility Django 1.10 --- .travis.yml | 47 ++++++------------------------------- README.rst | 4 ++-- multi_email_field/fields.py | 14 ++++------- 3 files changed, 14 insertions(+), 51 deletions(-) diff --git a/.travis.yml b/.travis.yml index 0a7d5d6..b5203ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,23 +1,19 @@ language: python python: - - 2.6 - 2.7 - 3.3 - 3.4 - 3.5 env: - - DJANGO_VERSION=1.4 MODULE=multi_email_field - - DJANGO_VERSION=1.5 MODULE=multi_email_field - - DJANGO_VERSION=1.6 MODULE=multi_email_field.tests - - DJANGO_VERSION=1.7 MODULE=multi_email_field.tests - - DJANGO_VERSION=1.8 MODULE=multi_email_field.tests - - DJANGO_VERSION=1.9 MODULE=multi_email_field.tests + - DJANGO_VERSION=1.8.14 MODULE=multi_email_field.tests + - DJANGO_VERSION=1.9.9 MODULE=multi_email_field.tests + - DJANGO_VERSION=1.10 MODULE=multi_email_field.tests install: - pip install six pyquery - - pip install -q Django==$DJANGO_VERSION --use-mirrors + - pip install -q Django==$DJANGO_VERSION - pip install coverage script: coverage run quicktest.py $MODULE @@ -26,39 +22,10 @@ after_success: - pip install coveralls - coveralls -# We need to exclude old versions of Django for tests with python 3. -# We need to exclude old versions of Python for tests with Django >= 1.7. +# We need to exclude old versions of Python for tests with Django >= 1.9. matrix: exclude: - python: 3.3 - env: DJANGO_VERSION=1.4 MODULE=multi_email_field - - python: 3.4 - env: DJANGO_VERSION=1.4 MODULE=multi_email_field - - python: 3.5 - env: DJANGO_VERSION=1.4 MODULE=multi_email_field + env: DJANGO_VERSION=1.9.9 MODULE=multi_email_field.tests - python: 3.3 - env: DJANGO_VERSION=1.5 MODULE=multi_email_field - - python: 3.4 - env: DJANGO_VERSION=1.5 MODULE=multi_email_field - - python: 3.5 - env: DJANGO_VERSION=1.5 MODULE=multi_email_field - - python: 3.3 - env: DJANGO_VERSION=1.6 MODULE=multi_email_field - - python: 3.4 - env: DJANGO_VERSION=1.6 MODULE=multi_email_field.tests - - python: 3.5 - env: DJANGO_VERSION=1.6 MODULE=multi_email_field.tests - - python: 2.6 - env: DJANGO_VERSION=1.7 MODULE=multi_email_field.tests - - python: 3.5 - env: DJANGO_VERSION=1.7 MODULE=multi_email_field.tests - - python: 2.6 - env: DJANGO_VERSION=1.8 MODULE=multi_email_field.tests - - python: 2.7 - env: DJANGO_VERSION=1.8 MODULE=multi_email_field.tests - - python: 2.6 - env: DJANGO_VERSION=1.9 MODULE=multi_email_field.tests - - python: 2.7 - env: DJANGO_VERSION=1.9 MODULE=multi_email_field.tests - - python: 3.3 - env: DJANGO_VERSION=1.9 MODULE=multi_email_field.tests + env: DJANGO_VERSION=1.10 MODULE=multi_email_field.tests diff --git a/README.rst b/README.rst index 9862425..f91693f 100644 --- a/README.rst +++ b/README.rst @@ -9,8 +9,8 @@ It provides: COMPATIBILITY ================== -* Python 2.6/2.7/3.3/3.4/3.5 -* Django 1.4/1.5/1.6/1.7/1.8/1.9 +* Python 2.7/3.3/3.4/3.5 +* Django 1.8/1.9/1.10 ================== INSTALL diff --git a/multi_email_field/fields.py b/multi_email_field/fields.py index a81b50a..5d97bef 100644 --- a/multi_email_field/fields.py +++ b/multi_email_field/fields.py @@ -8,8 +8,6 @@ class MultiEmailField(models.Field): description = "A multi e-mail field stored as a multi-lines text" - __metaclass__ = models.SubfieldBase - def formfield(self, **kwargs): # This is a fairly standard way to set up some defaults # while letting the caller override them. @@ -17,6 +15,11 @@ def formfield(self, **kwargs): defaults.update(kwargs) return super(MultiEmailField, self).formfield(**defaults) + def from_db_value(self, value, expression, connection, context): + if value is None: + return [] + return value.splitlines() + def get_db_prep_value(self, value, connection, prepared=False): if isinstance(value, six.string_types): return value @@ -32,10 +35,3 @@ def to_python(self, value): def get_internal_type(self): return 'TextField' - - -try: - from south.modelsinspector import add_introspection_rules - add_introspection_rules([], ["multi_email_field.fields.MultiEmailField"]) -except ImportError: - pass