PageRenderTime 19ms CodeModel.GetById 16ms RepoModel.GetById 0ms 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
Possible License(s): BSD-3-Clause
  1. """
  2. Regression tests for proper working of ForeignKey(null=True).
  3. """
  4. from django.db import models
  5. class SystemDetails(models.Model):
  6. details = models.TextField()
  7. class SystemInfo(models.Model):
  8. system_details = models.ForeignKey(SystemDetails)
  9. system_name = models.CharField(max_length=32)
  10. class Forum(models.Model):
  11. system_info = models.ForeignKey(SystemInfo)
  12. forum_name = models.CharField(max_length=32)
  13. class Post(models.Model):
  14. forum = models.ForeignKey(Forum, null=True)
  15. title = models.CharField(max_length=32)
  16. def __unicode__(self):
  17. return self.title
  18. class Comment(models.Model):
  19. post = models.ForeignKey(Post, null=True)
  20. comment_text = models.CharField(max_length=250)
  21. class Meta:
  22. ordering = ('comment_text',)
  23. def __unicode__(self):
  24. return self.comment_text