1
from django.db import models
3
class Author(models.Model):
4
first_name = models.CharField(max_length=255)
5
last_name = models.CharField(max_length=255)
6
dob = models.DateField()
8
def __init__(self, *args, **kwargs):
9
super(Author, self).__init__(*args, **kwargs)
10
# Protect against annotations being passed to __init__ --
11
# this'll make the test suite get angry if annotations aren't
12
# treated differently than fields.
14
assert k in [f.attname for f in self._meta.fields], \
15
"Author.__init__ got an unexpected paramater: %s" % k
17
class Book(models.Model):
18
title = models.CharField(max_length=255)
19
author = models.ForeignKey(Author)
20
paperback = models.BooleanField()
21
opening_line = models.TextField()
23
class Coffee(models.Model):
24
brand = models.CharField(max_length=255, db_column="name")
26
class Reviewer(models.Model):
27
reviewed = models.ManyToManyField(Book)
29
class FriendlyAuthor(Author):