/tests/modeltests/raw_query/models.py

https://code.google.com/p/mango-py/ · Python · 30 lines · 21 code · 6 blank · 3 comment · 2 complexity · 30496aab3dacd06b6b347fe3904c3f1a MD5 · raw file

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