summaryrefslogtreecommitdiff
path: root/tests/shared_models
diff options
context:
space:
mode:
authorFlorian Apolloner <florian@apolloner.eu>2013-03-13 23:25:26 +0100
committerFlorian Apolloner <florian@apolloner.eu>2013-03-13 23:25:26 +0100
commit22b7870e40a3ecf022b423de6cd867dcb35a6940 (patch)
tree4c9930270b83bebf3947ca00166462022024c4f2 /tests/shared_models
parent1059da8de675442e84381d6366c0be254681753e (diff)
Began implementing a shared set of test models to speed up tests.
Diffstat (limited to 'tests/shared_models')
-rw-r--r--tests/shared_models/models.py17
1 files changed, 12 insertions, 5 deletions
diff --git a/tests/shared_models/models.py b/tests/shared_models/models.py
index 61b3669bc4..145edad1bf 100644
--- a/tests/shared_models/models.py
+++ b/tests/shared_models/models.py
@@ -1,3 +1,5 @@
+from __future__ import unicode_literals
+
from django.db import models
from django.utils import timezone
from django.utils.encoding import python_2_unicode_compatible
@@ -9,7 +11,11 @@ class Tag(models.Model):
@python_2_unicode_compatible
class Author(models.Model):
- name = models.CharField(max_length=100)
+ name = models.CharField(max_length=100, help_text='Use both first and last names.',
+ unique=True)
+
+ class Meta:
+ ordering = ['name']
def __str__(self):
return self.name
@@ -17,14 +23,15 @@ class Author(models.Model):
@python_2_unicode_compatible
class Book(models.Model):
- name = models.CharField(max_length=200)
+ title = models.CharField(max_length=200)
pages = models.IntegerField(default=0)
- author = models.ForeignKey(Author, null=True)
+ author = models.ForeignKey(Author, null=True, blank=True)
pubdate = models.DateTimeField()
tags = models.ManyToManyField(Tag)
class Meta:
- ordering = ['-pubdate', 'name']
+ ordering = ['-pubdate', 'title']
+ unique_together = ['title', 'author']
def __str__(self):
- return self.name
+ return self.title