graphene/tests/contrib_django/models.py

33 lines
877 B
Python
Raw Normal View History

2015-09-28 10:34:25 +03:00
from __future__ import absolute_import
from django.db import models
2015-10-03 08:17:51 +03:00
class Pet(models.Model):
name = models.CharField(max_length=30)
2015-09-28 10:34:25 +03:00
class Reporter(models.Model):
first_name = models.CharField(max_length=30)
last_name = models.CharField(max_length=30)
email = models.EmailField()
pets = models.ManyToManyField('self')
2015-09-28 10:34:25 +03:00
def __str__(self): # __unicode__ on Python 2
return "%s %s" % (self.first_name, self.last_name)
class Meta:
2015-09-30 10:11:40 +03:00
app_label = 'contrib_django'
2015-09-28 10:34:25 +03:00
2015-10-03 08:17:51 +03:00
2015-09-28 10:34:25 +03:00
class Article(models.Model):
headline = models.CharField(max_length=100)
pub_date = models.DateField()
reporter = models.ForeignKey(Reporter, related_name='articles')
def __str__(self): # __unicode__ on Python 2
return self.headline
class Meta:
ordering = ('headline',)
2015-09-30 10:11:40 +03:00
app_label = 'contrib_django'