mirror of
https://github.com/graphql-python/graphene-django.git
synced 2024-12-03 06:53:46 +03:00
Merge pull request #336 from urbandove/django2
support Django 2 + in tests
This commit is contained in:
commit
883d1778d5
|
@ -38,6 +38,12 @@ env:
|
||||||
matrix:
|
matrix:
|
||||||
fast_finish: true
|
fast_finish: true
|
||||||
include:
|
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'
|
- python: '2.7'
|
||||||
env: TEST_TYPE=build DJANGO_VERSION=1.8
|
env: TEST_TYPE=build DJANGO_VERSION=1.8
|
||||||
- python: '2.7'
|
- python: '2.7'
|
||||||
|
|
|
@ -5,7 +5,7 @@ from django.db import models
|
||||||
|
|
||||||
class Character(models.Model):
|
class Character(models.Model):
|
||||||
name = models.CharField(max_length=50)
|
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):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
@ -13,7 +13,7 @@ class Character(models.Model):
|
||||||
|
|
||||||
class Faction(models.Model):
|
class Faction(models.Model):
|
||||||
name = models.CharField(max_length=50)
|
name = models.CharField(max_length=50)
|
||||||
hero = models.ForeignKey(Character)
|
hero = models.ForeignKey(Character, on_delete=models.CASCADE)
|
||||||
|
|
||||||
def __str__(self):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
@ -21,7 +21,7 @@ class Faction(models.Model):
|
||||||
|
|
||||||
class Ship(models.Model):
|
class Ship(models.Model):
|
||||||
name = models.CharField(max_length=50)
|
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):
|
def __str__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
|
@ -57,7 +57,11 @@ class GrapheneFilterSetMixin(BaseFilterSet):
|
||||||
Global IDs (the default implementation expects database
|
Global IDs (the default implementation expects database
|
||||||
primary keys)
|
primary keys)
|
||||||
"""
|
"""
|
||||||
rel = f.field.remote_field if hasattr(f.field, 'remote_field') else f.field.rel
|
try:
|
||||||
|
rel = f.field.remote_field
|
||||||
|
except AttributeError:
|
||||||
|
rel = f.field.rel
|
||||||
|
|
||||||
default = {
|
default = {
|
||||||
'name': name,
|
'name': name,
|
||||||
'label': capfirst(rel.related_name)
|
'label': capfirst(rel.related_name)
|
||||||
|
|
|
@ -15,7 +15,7 @@ class Pet(models.Model):
|
||||||
|
|
||||||
class FilmDetails(models.Model):
|
class FilmDetails(models.Model):
|
||||||
location = models.CharField(max_length=30)
|
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):
|
class Film(models.Model):
|
||||||
|
@ -74,8 +74,8 @@ class Article(models.Model):
|
||||||
headline = models.CharField(max_length=100)
|
headline = models.CharField(max_length=100)
|
||||||
pub_date = models.DateField()
|
pub_date = models.DateField()
|
||||||
pub_date_time = models.DateTimeField()
|
pub_date_time = models.DateTimeField()
|
||||||
reporter = models.ForeignKey(Reporter, related_name='articles')
|
reporter = models.ForeignKey(Reporter, on_delete=models.CASCADE, related_name='articles')
|
||||||
editor = models.ForeignKey(Reporter, related_name='edited_articles_+')
|
editor = models.ForeignKey(Reporter, on_delete=models.CASCADE, related_name='edited_articles_+')
|
||||||
lang = models.CharField(max_length=2, help_text='Language', choices=[
|
lang = models.CharField(max_length=2, help_text='Language', choices=[
|
||||||
('es', 'Spanish'),
|
('es', 'Spanish'),
|
||||||
('en', 'English')
|
('en', 'English')
|
||||||
|
|
2
setup.py
2
setup.py
|
@ -21,7 +21,7 @@ tests_require = [
|
||||||
'mock',
|
'mock',
|
||||||
'pytz',
|
'pytz',
|
||||||
'django-filter',
|
'django-filter',
|
||||||
'pytest-django==2.9.1',
|
'pytest-django>=3.2.1',
|
||||||
] + rest_framework_require
|
] + rest_framework_require
|
||||||
|
|
||||||
django_version = 'Django>=1.8.0,<2' if sys.version_info[0] < 3 else 'Django>=1.8.0'
|
django_version = 'Django>=1.8.0,<2' if sys.version_info[0] < 3 else 'Django>=1.8.0'
|
||||||
|
|
Loading…
Reference in New Issue
Block a user