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
|
|
|
|
|
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):
|
2015-07-22 14:43:21 +00:00
|
|
|
system_details = models.ForeignKey(SystemDetails, models.CASCADE)
|
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):
|
2015-07-22 14:43:21 +00:00
|
|
|
system_info = models.ForeignKey(SystemInfo, models.CASCADE)
|
2008-06-08 18:13:46 +00:00
|
|
|
forum_name = models.CharField(max_length=32)
|
|
|
|
|
2013-11-02 21:34:05 +00:00
|
|
|
|
2008-06-08 18:13:46 +00:00
|
|
|
class Post(models.Model):
|
2015-07-22 14:43:21 +00:00
|
|
|
forum = models.ForeignKey(Forum, models.SET_NULL, null=True)
|
2008-06-08 18:13:46 +00:00
|
|
|
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
|
|
|
|
2008-06-08 18:13:46 +00:00
|
|
|
class Comment(models.Model):
|
2015-07-22 14:43:21 +00:00
|
|
|
post = models.ForeignKey(Post, models.SET_NULL, null=True)
|
2008-06-08 18:13:46 +00:00
|
|
|
comment_text = models.CharField(max_length=250)
|
|
|
|
|
2009-06-29 12:29:48 +00:00
|
|
|
class Meta:
|
|
|
|
ordering = ("comment_text",)
|
2022-02-03 19:24:19 +00:00
|
|
|
|
2009-06-29 12:29:48 +00:00
|
|
|
|
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):
|
2015-07-22 14:43:21 +00:00
|
|
|
item = models.ForeignKey(Item, models.CASCADE, related_name="props")
|
2011-05-05 20:26:26 +00:00
|
|
|
key = models.CharField(max_length=100)
|
2015-07-22 14:43:21 +00:00
|
|
|
value = models.ForeignKey(PropertyValue, models.SET_NULL, null=True)
|