PageRenderTime 222ms CodeModel.GetById 110ms app.highlight 6ms RepoModel.GetById 105ms app.codeStats 0ms

/tests/regressiontests/select_related_onetoone/models.py

https://code.google.com/p/mango-py/
Python | 54 lines | 34 code | 20 blank | 0 comment | 0 complexity | 4facf8ca29530a94c81536d6dbf2ac4d MD5 | raw file
 1from django.db import models
 2
 3
 4class User(models.Model):
 5    username = models.CharField(max_length=100)
 6    email = models.EmailField()
 7
 8    def __unicode__(self):
 9        return self.username
10
11
12class UserProfile(models.Model):
13    user = models.OneToOneField(User)
14    city = models.CharField(max_length=100)
15    state = models.CharField(max_length=2)
16
17    def __unicode__(self):
18        return "%s, %s" % (self.city, self.state)
19
20
21class UserStatResult(models.Model):
22    results = models.CharField(max_length=50)
23
24    def __unicode__(self):
25        return 'UserStatResults, results = %s' % (self.results,)
26
27
28class UserStat(models.Model):
29    user = models.OneToOneField(User, primary_key=True)
30    posts = models.IntegerField()
31    results = models.ForeignKey(UserStatResult)
32
33    def __unicode__(self):
34        return 'UserStat, posts = %s' % (self.posts,)
35
36
37class StatDetails(models.Model):
38    base_stats = models.OneToOneField(UserStat)
39    comments = models.IntegerField()
40
41    def __unicode__(self):
42        return 'StatDetails, comments = %s' % (self.comments,)
43
44
45class AdvancedUserStat(UserStat):
46    karma = models.IntegerField()
47
48class Image(models.Model):
49    name = models.CharField(max_length=100)
50
51
52class Product(models.Model):
53    name = models.CharField(max_length=100)
54    image = models.OneToOneField(Image, null=True)