PageRenderTime 182ms CodeModel.GetById 101ms app.highlight 3ms RepoModel.GetById 77ms app.codeStats 0ms

/tests/regressiontests/null_fk/models.py

https://code.google.com/p/mango-py/
Python | 33 lines | 21 code | 9 blank | 3 comment | 0 complexity | ead039a6df8bb8f3dcf082a98a17df53 MD5 | raw file
 1"""
 2Regression tests for proper working of ForeignKey(null=True).
 3"""
 4
 5from django.db import models
 6
 7class SystemDetails(models.Model):
 8    details = models.TextField()
 9
10class SystemInfo(models.Model):
11    system_details = models.ForeignKey(SystemDetails)
12    system_name = models.CharField(max_length=32)
13
14class Forum(models.Model):
15    system_info = models.ForeignKey(SystemInfo)
16    forum_name = models.CharField(max_length=32)
17
18class Post(models.Model):
19    forum = models.ForeignKey(Forum, null=True)
20    title = models.CharField(max_length=32)
21
22    def __unicode__(self):
23        return self.title
24
25class Comment(models.Model):
26    post = models.ForeignKey(Post, null=True)
27    comment_text = models.CharField(max_length=250)
28
29    class Meta:
30        ordering = ('comment_text',)
31
32    def __unicode__(self):
33        return self.comment_text