2008-06-08 18:13:46 +00:00
|
|
|
"""
|
2008-07-27 01:18:23 +00:00
|
|
|
Regression tests for proper working of ForeignKey(null=True).
|
2008-06-08 18:13:46 +00:00
|
|
|
"""
|
|
|
|
|
|
|
|
from django.db import models
|
2012-08-12 10:32:08 +00:00
|
|
|
from django.utils.encoding import python_2_unicode_compatible
|
2008-06-08 18:13:46 +00:00
|
|
|
|
2011-10-13 21:34:56 +00:00
|
|
|
|
2010-03-08 12:47:16 +00:00
|
|
|
class SystemDetails(models.Model):
|
|
|
|
details = models.TextField()
|
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2008-06-08 18:13:46 +00:00
|
|
|
class SystemInfo(models.Model):
|
2010-03-08 12:47:16 +00:00
|
|
|
system_details = models.ForeignKey(SystemDetails)
|
2008-06-08 18:13:46 +00:00
|
|
|
system_name = models.CharField(max_length=32)
|
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2008-06-08 18:13:46 +00:00
|
|
|
class Forum(models.Model):
|
|
|
|
system_info = models.ForeignKey(SystemInfo)
|
|
|
|
forum_name = models.CharField(max_length=32)
|
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
2008-06-08 18:13:46 +00:00
|
|
|
class Post(models.Model):
|
|
|
|
forum = models.ForeignKey(Forum, null=True)
|
|
|
|
title = models.CharField(max_length=32)
|
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2008-06-08 18:13:46 +00:00
|
|
|
return self.title
|
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
@python_2_unicode_compatible
|
2008-06-08 18:13:46 +00:00
|
|
|
class Comment(models.Model):
|
|
|
|
post = models.ForeignKey(Post, null=True)
|
|
|
|
comment_text = models.CharField(max_length=250)
|
|
|
|
|
2009-06-29 12:29:48 +00:00
|
|
|
class Meta:
|
|
|
|
ordering = ('comment_text',)
|
|
|
|
|
2012-08-12 10:32:08 +00:00
|
|
|
def __str__(self):
|
2008-06-08 18:13:46 +00:00
|
|
|
return self.comment_text
|
2011-05-05 20:26:26 +00:00
|
|
|
|
|
|
|
# Ticket 15823
|
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2011-05-05 20:26:26 +00:00
|
|
|
class Item(models.Model):
|
|
|
|
title = models.CharField(max_length=100)
|
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2011-05-05 20:26:26 +00:00
|
|
|
class PropertyValue(models.Model):
|
|
|
|
label = models.CharField(max_length=100)
|
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2011-05-05 20:26:26 +00:00
|
|
|
class Property(models.Model):
|
|
|
|
item = models.ForeignKey(Item, related_name='props')
|
|
|
|
key = models.CharField(max_length=100)
|
|
|
|
value = models.ForeignKey(PropertyValue, null=True)
|