PageRenderTime 273ms CodeModel.GetById 100ms app.highlight 18ms RepoModel.GetById 83ms app.codeStats 38ms

/tests/modeltests/aggregation/models.py

https://code.google.com/p/mango-py/
Python | 42 lines | 31 code | 10 blank | 1 comment | 0 complexity | ee029b68199ed1923168e61b701e7bae 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
13class Publisher(models.Model):
14    name = models.CharField(max_length=255)
15    num_awards = models.IntegerField()
16
17    def __unicode__(self):
18        return self.name
19
20class Book(models.Model):
21    isbn = models.CharField(max_length=9)
22    name = models.CharField(max_length=255)
23    pages = models.IntegerField()
24    rating = models.FloatField()
25    price = models.DecimalField(decimal_places=2, max_digits=6)
26    authors = models.ManyToManyField(Author)
27    contact = models.ForeignKey(Author, related_name='book_contact_set')
28    publisher = models.ForeignKey(Publisher)
29    pubdate = models.DateField()
30
31    def __unicode__(self):
32        return self.name
33
34class Store(models.Model):
35    name = models.CharField(max_length=255)
36    books = models.ManyToManyField(Book)
37    original_opening = models.DateTimeField()
38    friday_night_closing = models.TimeField()
39
40    def __unicode__(self):
41        return self.name
42