From 3df9bcafa4a2c67b9b916bb43c3f654c59f83bae Mon Sep 17 00:00:00 2001 From: Andrew Davison Date: Sun, 7 Jun 2020 21:53:03 +0200 Subject: [PATCH] Changes to work with Django >= 1.8 (#376) * Changes to work with Django >= 1.8 * Limit to Django v 1.x * Trying to fix Travis errors * (still) Trying to fix Travis errors * Stop testing against Python 3.5 --- .travis.yml | 1 - README.rst | 2 +- ci/requirements-3.4.txt | 2 -- ci/requirements-3.5.txt | 2 -- ci/requirements.txt | 2 +- doc/developers_guide.txt | 2 +- doc/installation.txt | 2 +- setup.py | 2 +- sumatra/recordstore/django_store/__init__.py | 5 +---- sumatra/recordstore/django_store/models.py | 4 ++-- 10 files changed, 8 insertions(+), 16 deletions(-) delete mode 100644 ci/requirements-3.4.txt delete mode 100644 ci/requirements-3.5.txt diff --git a/.travis.yml b/.travis.yml index 6ef74085..ae38afd3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -2,7 +2,6 @@ language: python sudo: required python: - "2.7" - - "3.5" - "3.6" - "3.7" env: diff --git a/README.rst b/README.rst index 15882fd6..f5322154 100644 --- a/README.rst +++ b/README.rst @@ -50,7 +50,7 @@ Requirements ============ Sumatra requires Python versions 2.7, 3.4, 3.5 or 3.6. The web interface requires -Django (>= 1.6 < 1.9) and the django-tagging package. +Django (>= 1.8) and the django-tagging package. Sumatra requires that you keep your own code in a version control system (currently Subversion, Mercurial, Git and Bazaar are supported). If you are already using Bazaar there is nothing else to install. If you diff --git a/ci/requirements-3.4.txt b/ci/requirements-3.4.txt deleted file mode 100644 index 2976358a..00000000 --- a/ci/requirements-3.4.txt +++ /dev/null @@ -1,2 +0,0 @@ -# Additional requirements for Python 3.4 -pyyaml # this is already in requirements.txt, but pip doesn't allow empty requirements files diff --git a/ci/requirements-3.5.txt b/ci/requirements-3.5.txt deleted file mode 100644 index 9edef4fb..00000000 --- a/ci/requirements-3.5.txt +++ /dev/null @@ -1,2 +0,0 @@ -# Additional requirements for Python 3.5 -pyyaml # this is already in requirements.txt, but pip doesn't allow empty requirements files diff --git a/ci/requirements.txt b/ci/requirements.txt index 0dfb59cc..bccc6834 100644 --- a/ci/requirements.txt +++ b/ci/requirements.txt @@ -1,5 +1,5 @@ # Base requirements for running Sumatra, for all supported versions of Python -Django>=1.6, <1.9 +Django>=1.8 django-tagging>=0.4 httplib2 jinja2 diff --git a/doc/developers_guide.txt b/doc/developers_guide.txt index 097a8b30..65d0aa9b 100644 --- a/doc/developers_guide.txt +++ b/doc/developers_guide.txt @@ -10,7 +10,7 @@ Requirements ------------ * Python_ 2.7, 3.4, 3.5 or 3.6 - * Django_ >= 1.6 < 1.9 + * Django_ >= 1.8 * django-tagging_ >= 0.3 * parameters >= 0.2.1 * nose_ >= 0.11.4 diff --git a/doc/installation.txt b/doc/installation.txt index 35e2943d..664c665f 100644 --- a/doc/installation.txt +++ b/doc/installation.txt @@ -29,7 +29,7 @@ Installing Django ----------------- If you wish to use the web interface, you will also need to install Django_ -version 1.6 or later. On Linux, you may be able to do this via your package +version 1.8 or later. On Linux, you may be able to do this via your package management system: see https://code.djangoproject.com/wiki/Distributions. Otherwise, it is very easy to install manually: see diff --git a/setup.py b/setup.py index 8e0b2804..adda6c56 100644 --- a/setup.py +++ b/setup.py @@ -27,7 +27,7 @@ def get_tip_revision(self, path=os.getcwd()): return repo.head.commit.hexsha[:7] -install_requires = ['Django>=1.6, <1.9', 'django-tagging', 'httplib2', +install_requires = ['Django>=1.8, <2', 'django-tagging', 'httplib2', 'docutils', 'jinja2', 'parameters', 'future'] major_python_version, minor_python_version, _, _, _ = sys.version_info if major_python_version < 3 or (major_python_version == 3 and minor_python_version < 4): diff --git a/sumatra/recordstore/django_store/__init__.py b/sumatra/recordstore/django_store/__init__.py index e327afb1..73ed7cd0 100644 --- a/sumatra/recordstore/django_store/__init__.py +++ b/sumatra/recordstore/django_store/__init__.py @@ -116,10 +116,7 @@ def _create_databases(self): db_file = db['NAME'] if not os.path.exists(os.path.dirname(db_file)): os.makedirs(os.path.dirname(db_file)) - try: - management.call_command('migrate', database=label, verbosity=0) - except django.core.management.base.CommandError: - management.call_command('syncdb', database=label, verbosity=0) + management.call_command('migrate', run_syncdb=True, database=label, verbosity=0, interactive=False) def configure(self): settings = django_conf.settings diff --git a/sumatra/recordstore/django_store/models.py b/sumatra/recordstore/django_store/models.py index 966cd1d0..cfa8137d 100644 --- a/sumatra/recordstore/django_store/models.py +++ b/sumatra/recordstore/django_store/models.py @@ -33,7 +33,7 @@ def get_or_create_from_sumatra_object(self, obj, using='default'): # might be better to specify the list of field names explicitly # as an argument to the Manager __init__(). excluded_fields = ('id', 'record', 'input_to_records', 'output_from_record', 'output_from_record_id') - field_names = set(self.model._meta.get_all_field_names()).difference(excluded_fields) + field_names = set([f.name for f in self.model._meta.get_fields()]).difference(excluded_fields) attributes = {} for name in field_names: if name == 'metadata': @@ -61,7 +61,7 @@ class Meta(object): abstract = True def field_names(self): - field_names = self._meta.get_all_field_names() + field_names = [f.name for f in self._meta.get_fields()] field_names.remove('id') field_names.remove('record') return field_names