~ubuntu-branches/ubuntu/saucy/python-django/saucy-updates

« back to all changes in this revision

Viewing changes to tests/modeltests/raw_query/models.py

  • Committer: Bazaar Package Importer
  • Author(s): Chris Lamb
  • Date: 2010-05-21 07:52:55 UTC
  • mfrom: (1.3.6 upstream)
  • mto: This revision was merged to the branch mainline in revision 28.
  • Revision ID: james.westby@ubuntu.com-20100521075255-ii78v1dyfmyu3uzx
Tags: upstream-1.2
ImportĀ upstreamĀ versionĀ 1.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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