summaryrefslogtreecommitdiff
path: root/tests/contenttypes_tests/models.py
diff options
context:
space:
mode:
Diffstat (limited to 'tests/contenttypes_tests/models.py')
-rw-r--r--tests/contenttypes_tests/models.py22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/contenttypes_tests/models.py b/tests/contenttypes_tests/models.py
index a302fe97f0..4b9d3d31e6 100644
--- a/tests/contenttypes_tests/models.py
+++ b/tests/contenttypes_tests/models.py
@@ -4,12 +4,22 @@ from django.contrib.contenttypes.fields import (
GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
+from django.contrib.sites.models import SiteManager
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
from django.utils.http import urlquote
@python_2_unicode_compatible
+class Site(models.Model):
+ domain = models.CharField(max_length=100)
+ objects = SiteManager()
+
+ def __str__(self):
+ return self.domain
+
+
+@python_2_unicode_compatible
class Author(models.Model):
name = models.CharField(max_length=100)
@@ -115,3 +125,15 @@ class Post(models.Model):
def __str__(self):
return self.title
+
+
+@python_2_unicode_compatible
+class ModelWithNullFKToSite(models.Model):
+ title = models.CharField(max_length=200)
+ site = models.ForeignKey(Site, null=True, on_delete=models.CASCADE)
+
+ def __str__(self):
+ return self.title
+
+ def get_absolute_url(self):
+ return '/title/%s/' % urlquote(self.title)