From d314d1041fc86bf08224bf0ddb8da7f7d279cd5b Mon Sep 17 00:00:00 2001 From: = <=> Date: Wed, 6 Dec 2017 12:45:03 -0500 Subject: [PATCH 1/7] rel -> remote_field: Update Django DeprecatedAttribute --- graphene_django/filter/filterset.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphene_django/filter/filterset.py b/graphene_django/filter/filterset.py index c716b05..4873f71 100644 --- a/graphene_django/filter/filterset.py +++ b/graphene_django/filter/filterset.py @@ -57,7 +57,7 @@ class GrapheneFilterSetMixin(BaseFilterSet): Global IDs (the default implementation expects database primary keys) """ - rel = f.field.rel + rel = f.field.remote_field default = { 'name': name, 'label': capfirst(rel.related_name) From 384bff08e8fa6fb61cf41be81d914ddb65d70a03 Mon Sep 17 00:00:00 2001 From: = <=> Date: Wed, 6 Dec 2017 13:10:03 -0500 Subject: [PATCH 2/7] Add fallback for depracated atrribute --- graphene_django/filter/filterset.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/graphene_django/filter/filterset.py b/graphene_django/filter/filterset.py index 4873f71..231a8e1 100644 --- a/graphene_django/filter/filterset.py +++ b/graphene_django/filter/filterset.py @@ -57,7 +57,10 @@ class GrapheneFilterSetMixin(BaseFilterSet): Global IDs (the default implementation expects database primary keys) """ - rel = f.field.remote_field + try: + rel = f.field.remote_field + except AttributeError: + rel = f.field.rel default = { 'name': name, 'label': capfirst(rel.related_name) From 489d2878da1d3563930c47329baffe08a8af5e38 Mon Sep 17 00:00:00 2001 From: = <=> Date: Wed, 6 Dec 2017 15:10:50 -0500 Subject: [PATCH 3/7] django version depends on python version --- setup.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/setup.py b/setup.py index beee83c..2e835d1 100644 --- a/setup.py +++ b/setup.py @@ -24,6 +24,7 @@ tests_require = [ 'pytest-django==2.9.1', ] + rest_framework_require +django_version = 'Django>=1.8.0,<2' if sys.version_info[0] < 3 else 'Django>=1.8.0' setup( name='graphene-django', version=version, @@ -58,7 +59,7 @@ setup( install_requires=[ 'six>=1.10.0', 'graphene>=2.0,<3', - 'Django>=1.8.0', + django_version, 'iso8601', 'singledispatch>=3.4.0.3', 'promise>=2.1', From f687406ac5f2b1b7ff55a0f1ae91dc1117f371c8 Mon Sep 17 00:00:00 2001 From: = <=> Date: Tue, 5 Dec 2017 15:01:52 -0500 Subject: [PATCH 4/7] Add on_delete atrributes to test models foreignkeys --- examples/starwars/models.py | 6 +++--- graphene_django/tests/models.py | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/examples/starwars/models.py b/examples/starwars/models.py index 2f80e27..45741da 100644 --- a/examples/starwars/models.py +++ b/examples/starwars/models.py @@ -5,7 +5,7 @@ from django.db import models class Character(models.Model): name = models.CharField(max_length=50) - ship = models.ForeignKey('Ship', blank=True, null=True, related_name='characters') + ship = models.ForeignKey('Ship', on_delete=models.CASCADE, blank=True, null=True, related_name='characters') def __str__(self): return self.name @@ -13,7 +13,7 @@ class Character(models.Model): class Faction(models.Model): name = models.CharField(max_length=50) - hero = models.ForeignKey(Character) + hero = models.ForeignKey(Character, on_delete=models.CASCADE) def __str__(self): return self.name @@ -21,7 +21,7 @@ class Faction(models.Model): class Ship(models.Model): name = models.CharField(max_length=50) - faction = models.ForeignKey(Faction, related_name='ships') + faction = models.ForeignKey(Faction, on_delete=models.CASCADE, related_name='ships') def __str__(self): return self.name diff --git a/graphene_django/tests/models.py b/graphene_django/tests/models.py index 0c62f28..db1fca4 100644 --- a/graphene_django/tests/models.py +++ b/graphene_django/tests/models.py @@ -15,7 +15,7 @@ class Pet(models.Model): class FilmDetails(models.Model): location = models.CharField(max_length=30) - film = models.OneToOneField('Film', related_name='details') + film = models.OneToOneField('Film', on_delete=models.CASCADE, related_name='details') class Film(models.Model): @@ -37,8 +37,8 @@ class Reporter(models.Model): class Article(models.Model): headline = models.CharField(max_length=100) pub_date = models.DateField() - reporter = models.ForeignKey(Reporter, related_name='articles') - editor = models.ForeignKey(Reporter, related_name='edited_articles_+') + reporter = models.ForeignKey(Reporter, on_delete=models.CASCADE, related_name='articles') + editor = models.ForeignKey(Reporter, on_delete=models.CASCADE, related_name='edited_articles_+') lang = models.CharField(max_length=2, help_text='Language', choices=[ ('es', 'Spanish'), ('en', 'English') From 61829abc8c7d15587cc63866e907a1462f8deab3 Mon Sep 17 00:00:00 2001 From: = <=> Date: Thu, 7 Dec 2017 13:06:31 -0500 Subject: [PATCH 5/7] Add testing to django 2 --- .travis.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.travis.yml b/.travis.yml index ef8a3d6..d2349ed 100644 --- a/.travis.yml +++ b/.travis.yml @@ -38,6 +38,12 @@ env: matrix: fast_finish: true include: + - python: '3.4' + env: TEST_TYPE=build DJANGO_VERSION=2.0 + - python: '3.5' + env: TEST_TYPE=build DJANGO_VERSION=2.0 + - python: '3.6' + env: TEST_TYPE=build DJANGO_VERSION=2.0 - python: '2.7' env: TEST_TYPE=build DJANGO_VERSION=1.8 - python: '2.7' From ea2d60d3df082fca042d03f1d9cc480746f3af50 Mon Sep 17 00:00:00 2001 From: = <=> Date: Sun, 15 Apr 2018 00:13:49 -0400 Subject: [PATCH 6/7] update pytest django version --- setup.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/setup.py b/setup.py index 5e058b4..af630c7 100644 --- a/setup.py +++ b/setup.py @@ -21,7 +21,7 @@ tests_require = [ 'mock', 'pytz', 'django-filter', - 'pytest-django==2.9.1', + 'pytest-django>=3.2.1', ] + rest_framework_require django_version = 'Django>=1.8.0,<2' if sys.version_info[0] < 3 else 'Django>=1.8.0' From 43c0c99136a6ea4450485a232bc9637f926db9fe Mon Sep 17 00:00:00 2001 From: = <=> Date: Sun, 15 Apr 2018 00:21:53 -0400 Subject: [PATCH 7/7] fix lint error --- graphene_django/filter/filterset.py | 1 - 1 file changed, 1 deletion(-) diff --git a/graphene_django/filter/filterset.py b/graphene_django/filter/filterset.py index f812c44..0e33fe6 100644 --- a/graphene_django/filter/filterset.py +++ b/graphene_django/filter/filterset.py @@ -57,7 +57,6 @@ class GrapheneFilterSetMixin(BaseFilterSet): Global IDs (the default implementation expects database primary keys) """ - try: rel = f.field.remote_field except AttributeError: