diff options
| author | Andrew Godwin <andrew@aeracode.org> | 2011-01-10 13:45:36 +0000 |
|---|---|---|
| committer | Andrew Godwin <andrew@aeracode.org> | 2011-01-10 13:45:36 +0000 |
| commit | 663eb9656a92492bb43a5a29efed9d907dc8f6ae (patch) | |
| tree | 0d088ddcd47a86893ae125692bc1646b6573a627 /tests | |
| parent | 03ab30c3f10b5cf20698ae9ac7b56caa47a88552 (diff) | |
[1.2.X] Fix wrong attribute name in [15156]. Thanks to Alex Gaynor for spotting this.
Backport of [15169] from trunk
git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.2.X@15170 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/regressiontests/get_or_create_regress/models.py | 2 | ||||
| -rw-r--r-- | tests/regressiontests/get_or_create_regress/tests.py | 2 |
2 files changed, 3 insertions, 1 deletions
diff --git a/tests/regressiontests/get_or_create_regress/models.py b/tests/regressiontests/get_or_create_regress/models.py index 292d96c980..637bbf62af 100644 --- a/tests/regressiontests/get_or_create_regress/models.py +++ b/tests/regressiontests/get_or_create_regress/models.py @@ -10,4 +10,4 @@ class Author(models.Model): class Book(models.Model): name = models.CharField(max_length=100) authors = models.ManyToManyField(Author, related_name='books') - publisher = models.ForeignKey(Publisher, related_name='books') + publisher = models.ForeignKey(Publisher, related_name='books', db_column="publisher_id_column") diff --git a/tests/regressiontests/get_or_create_regress/tests.py b/tests/regressiontests/get_or_create_regress/tests.py index e825fccc4b..103e254d4c 100644 --- a/tests/regressiontests/get_or_create_regress/tests.py +++ b/tests/regressiontests/get_or_create_regress/tests.py @@ -55,8 +55,10 @@ class GetOrCreateTests(TestCase): # Use the publisher's primary key value instead of a model instance. _, created = ed.books.get_or_create(name='The Great Book of Ed', publisher_id=p.id) self.assertTrue(created) + # Try get_or_create again, this time nothing should be created. _, created = ed.books.get_or_create(name='The Great Book of Ed', publisher_id=p.id) self.assertFalse(created) + # The publisher should have three books. self.assertEqual(p.books.count(), 3) |
