graphene/graphene-django/examples/starwars/models.py

27 lines
540 B
Python
Raw Normal View History

2015-09-30 09:40:40 +03:00
from __future__ import absolute_import
2015-09-30 09:40:40 +03:00
from django.db import models
2015-10-11 00:53:46 +03:00
class Character(models.Model):
name = models.CharField(max_length=50)
def __str__(self):
return self.name
2015-09-30 09:40:40 +03:00
class Faction(models.Model):
name = models.CharField(max_length=50)
2015-10-11 00:53:46 +03:00
hero = models.ForeignKey(Character)
2015-09-30 09:40:40 +03:00
def __str__(self):
return self.name
class Ship(models.Model):
name = models.CharField(max_length=50)
faction = models.ForeignKey(Faction, related_name='ships')
def __str__(self):
return self.name