diff options
| author | Josh Smeaton <josh.smeaton@gmail.com> | 2013-12-26 00:13:18 +1100 |
|---|---|---|
| committer | Marc Tamlyn <marc.tamlyn@gmail.com> | 2014-11-15 14:00:43 +0000 |
| commit | f59fd15c4928caf3dfcbd50f6ab47be409a43b01 (patch) | |
| tree | fe4a04d98359e1ffcbfe991303eb97d9a8e16afc /tests/annotations/models.py | |
| parent | 39e3ef88c237e3f4cedc89cd36494a6d3f490812 (diff) | |
Fixed #14030 -- Allowed annotations to accept all expressions
Diffstat (limited to 'tests/annotations/models.py')
| -rw-r--r-- | tests/annotations/models.py | 86 |
1 files changed, 86 insertions, 0 deletions
diff --git a/tests/annotations/models.py b/tests/annotations/models.py new file mode 100644 index 0000000000..0c438b99f8 --- /dev/null +++ b/tests/annotations/models.py @@ -0,0 +1,86 @@ +# coding: utf-8 +from django.db import models +from django.utils.encoding import python_2_unicode_compatible + + +@python_2_unicode_compatible +class Author(models.Model): + name = models.CharField(max_length=100) + age = models.IntegerField() + friends = models.ManyToManyField('self', blank=True) + + def __str__(self): + return self.name + + +@python_2_unicode_compatible +class Publisher(models.Model): + name = models.CharField(max_length=255) + num_awards = models.IntegerField() + + def __str__(self): + return self.name + + +@python_2_unicode_compatible +class Book(models.Model): + isbn = models.CharField(max_length=9) + name = models.CharField(max_length=255) + pages = models.IntegerField() + rating = models.FloatField() + price = models.DecimalField(decimal_places=2, max_digits=6) + authors = models.ManyToManyField(Author) + contact = models.ForeignKey(Author, related_name='book_contact_set') + publisher = models.ForeignKey(Publisher) + pubdate = models.DateField() + + def __str__(self): + return self.name + + +@python_2_unicode_compatible +class Store(models.Model): + name = models.CharField(max_length=255) + books = models.ManyToManyField(Book) + original_opening = models.DateTimeField() + friday_night_closing = models.TimeField() + + def __str__(self): + return self.name + + +@python_2_unicode_compatible +class DepartmentStore(Store): + chain = models.CharField(max_length=255) + + def __str__(self): + return '%s - %s ' % (self.chain, self.name) + + +@python_2_unicode_compatible +class Employee(models.Model): + # The order of these fields matter, do not change. Certain backends + # rely on field ordering to perform database conversions, and this + # model helps to test that. + first_name = models.CharField(max_length=20) + manager = models.BooleanField(default=False) + last_name = models.CharField(max_length=20) + store = models.ForeignKey(Store) + age = models.IntegerField() + salary = models.DecimalField(max_digits=8, decimal_places=2) + + def __str__(self): + return '%s %s' % (self.first_name, self.last_name) + + +@python_2_unicode_compatible +class Company(models.Model): + name = models.CharField(max_length=200) + motto = models.CharField(max_length=200, null=True, blank=True) + ticker_name = models.CharField(max_length=10, null=True, blank=True) + description = models.CharField(max_length=200, null=True, blank=True) + + def __str__(self): + return ('Company(name=%s, motto=%s, ticker_name=%s, description=%s)' + % (self.name, self.motto, self.ticker_name, self.description) + ) |
