Skip to content

Commit

Permalink
undo cascade changes
Browse files Browse the repository at this point in the history
  • Loading branch information
jm2242 committed Feb 4, 2018
1 parent bc1d47e commit bfcfccf
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 31 deletions.
19 changes: 3 additions & 16 deletions examples/starwars/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,36 +5,23 @@

class Character(models.Model):
name = models.CharField(max_length=50)
ship = models.ForeignKey(
'Ship',
blank=True,
null=True,
on_delete=models.SET_NULL,
related_name='characters'
)
ship = models.ForeignKey('Ship', blank=True, null=True, related_name='characters')

def __str__(self):
return self.name


class Faction(models.Model):
name = models.CharField(max_length=50)
hero = models.ForeignKey(
Character,
on_delete=models.SET_NULL,
)
hero = models.ForeignKey(Character)

def __str__(self):
return self.name


class Ship(models.Model):
name = models.CharField(max_length=50)
faction = models.ForeignKey(
Faction,
on_delete=models.SET_NULL,
related_name='ships'
)
faction = models.ForeignKey(Faction, related_name='ships')

def __str__(self):
return self.name
18 changes: 3 additions & 15 deletions graphene_django/tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,7 @@ class Pet(models.Model):

class FilmDetails(models.Model):
location = models.CharField(max_length=30)
film = models.OneToOneField(
'Film',
on_delete=models.CASCADE,
related_name='details'
)
film = models.OneToOneField('Film', related_name='details')


class Film(models.Model):
Expand Down Expand Up @@ -68,16 +64,8 @@ class Meta:
class Article(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateField()
reporter = models.ForeignKey(
Reporter,
on_delete=models.SET_NULL,
related_name='articles'
)
editor = models.ForeignKey(
Reporter,
on_delete=models.SET_NULL,
related_name='edited_articles_+'
)
reporter = models.ForeignKey(Reporter, related_name='articles')
editor = models.ForeignKey(Reporter, related_name='edited_articles_+')
lang = models.CharField(max_length=2, help_text='Language', choices=[
('es', 'Spanish'),
('en', 'English')
Expand Down

0 comments on commit bfcfccf

Please sign in to comment.