/tests/modeltests/raw_query/models.py
Python | 30 lines | 21 code | 6 blank | 3 comment | 5 complexity | 30496aab3dacd06b6b347fe3904c3f1a MD5 | raw file
Possible License(s): BSD-3-Clause
1from django.db import models 2 3class 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 17class 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 23class Coffee(models.Model): 24 brand = models.CharField(max_length=255, db_column="name") 25 26class Reviewer(models.Model): 27 reviewed = models.ManyToManyField(Book) 28 29class FriendlyAuthor(Author): 30 pass