summaryrefslogtreecommitdiff
path: root/tests/get_or_create/models.py
diff options
context:
space:
mode:
authorFlorian Apolloner <florian@apolloner.eu>2013-02-26 09:53:47 +0100
committerFlorian Apolloner <florian@apolloner.eu>2013-02-26 14:36:57 +0100
commit89f40e36246100df6a11316c31a76712ebc6c501 (patch)
tree6e65639683ddaf2027908d1ecb1739e0e2ff853b /tests/get_or_create/models.py
parentb3d2ccb5bfbaf6e7fe1f98843baaa48c35a70950 (diff)
Merged regressiontests and modeltests into the test root.
Diffstat (limited to 'tests/get_or_create/models.py')
-rw-r--r--tests/get_or_create/models.py26
1 files changed, 26 insertions, 0 deletions
diff --git a/tests/get_or_create/models.py b/tests/get_or_create/models.py
new file mode 100644
index 0000000000..678f5a401c
--- /dev/null
+++ b/tests/get_or_create/models.py
@@ -0,0 +1,26 @@
+"""
+33. get_or_create()
+
+``get_or_create()`` does what it says: it tries to look up an object with the
+given parameters. If an object isn't found, it creates one with the given
+parameters.
+"""
+
+from __future__ import unicode_literals
+
+from django.db import models
+from django.utils.encoding import python_2_unicode_compatible
+
+
+@python_2_unicode_compatible
+class Person(models.Model):
+ first_name = models.CharField(max_length=100)
+ last_name = models.CharField(max_length=100)
+ birthday = models.DateField()
+
+ def __str__(self):
+ return '%s %s' % (self.first_name, self.last_name)
+
+class ManualPrimaryKeyTest(models.Model):
+ id = models.IntegerField(primary_key=True)
+ data = models.CharField(max_length=100)