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