PageRenderTime 29ms CodeModel.GetById 19ms app.highlight 7ms RepoModel.GetById 1ms app.codeStats 0ms

/tests/regressiontests/aggregation_regress/models.py

https://code.google.com/p/mango-py/
Python | 65 lines | 45 code | 19 blank | 1 comment | 0 complexity | d2f383136ff129842cbdff9959360575 MD5 | raw file
 1# coding: utf-8
 2from django.db import models
 3
 4
 5class Author(models.Model):
 6    name = models.CharField(max_length=100)
 7    age = models.IntegerField()
 8    friends = models.ManyToManyField('self', blank=True)
 9
10    def __unicode__(self):
11        return self.name
12
13
14class Publisher(models.Model):
15    name = models.CharField(max_length=255)
16    num_awards = models.IntegerField()
17
18    def __unicode__(self):
19        return self.name
20
21
22class Book(models.Model):
23    isbn = models.CharField(max_length=9)
24    name = models.CharField(max_length=255)
25    pages = models.IntegerField()
26    rating = models.FloatField()
27    price = models.DecimalField(decimal_places=2, max_digits=6)
28    authors = models.ManyToManyField(Author)
29    contact = models.ForeignKey(Author, related_name='book_contact_set')
30    publisher = models.ForeignKey(Publisher)
31    pubdate = models.DateField()
32
33    class Meta:
34        ordering = ('name',)
35
36    def __unicode__(self):
37        return self.name
38
39
40class Store(models.Model):
41    name = models.CharField(max_length=255)
42    books = models.ManyToManyField(Book)
43    original_opening = models.DateTimeField()
44    friday_night_closing = models.TimeField()
45
46    def __unicode__(self):
47        return self.name
48
49class Entries(models.Model):
50    EntryID = models.AutoField(primary_key=True, db_column='Entry ID')
51    Entry = models.CharField(unique=True, max_length=50)
52    Exclude = models.BooleanField()
53
54
55class Clues(models.Model):
56    ID = models.AutoField(primary_key=True)
57    EntryID = models.ForeignKey(Entries, verbose_name='Entry', db_column = 'Entry ID')
58    Clue = models.CharField(max_length=150)
59
60
61class HardbackBook(Book):
62    weight = models.FloatField()
63
64    def __unicode__(self):
65        return "%s (hardback): %s" % (self.name, self.weight)