1from django.db import models
2
3class Reporter(models.Model):
4 first_name = models.CharField(max_length=30)
5 last_name = models.CharField(max_length=30)
6 email = models.EmailField()
7
8 def __str__(self):
9 return "%s %s" % (self.first_name, self.last_name)
10
11class Article(models.Model):
12 headline = models.CharField(max_length=100)
13 pub_date = models.DateField()
14 reporter = models.ForeignKey(Reporter, on_delete=models.CASCADE)
15
16 def __str__(self):
17 return self.headline
18
19 class Meta:
20 ordering = ['headline']
21