parts/django/tests/modeltests/raw_query/models.py
changeset 69 c6bca38c1cbf
equal deleted inserted replaced
68:5ff1fc726848 69:c6bca38c1cbf
       
     1 from django.db import models
       
     2 
       
     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()
       
     7 
       
     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.
       
    13         for k in kwargs:
       
    14             assert k in [f.attname for f in self._meta.fields], \
       
    15                 "Author.__init__ got an unexpected paramater: %s" % k
       
    16 
       
    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()
       
    22 
       
    23 class Coffee(models.Model):
       
    24     brand = models.CharField(max_length=255, db_column="name")
       
    25 
       
    26 class Reviewer(models.Model):
       
    27     reviewed = models.ManyToManyField(Book)
       
    28 
       
    29 class FriendlyAuthor(Author):
       
    30     pass