diff --git a/tests/regressiontests/generic_relations_regress/models.py b/tests/regressiontests/generic_relations_regress/models.py
index 1a4826a..644bb98 100644
a
|
b
|
class Link(models.Model):
|
13 | 13 | class Place(models.Model): |
14 | 14 | name = models.CharField(max_length=100) |
15 | 15 | links = generic.GenericRelation(Link) |
16 | | |
| 16 | |
17 | 17 | def __unicode__(self): |
18 | 18 | return "Place: %s" % self.name |
19 | | |
20 | | class Restaurant(Place): |
| 19 | |
| 20 | class Restaurant(Place): |
21 | 21 | def __unicode__(self): |
22 | | return "Restaurant: %s" % self.name |
23 | | No newline at end of file |
| 22 | return "Restaurant: %s" % self.name |
| 23 | |
| 24 | class Item(models.Model): |
| 25 | links = generic.GenericRelation('Link') |
diff --git a/tests/regressiontests/generic_relations_regress/tests.py b/tests/regressiontests/generic_relations_regress/tests.py
index 6f0863d..dda4288 100644
a
|
b
|
|
1 | 1 | from django.test import TestCase |
2 | 2 | from django.contrib.contenttypes.models import ContentType |
3 | | from models import Link, Place, Restaurant |
| 3 | from models import Link, Place, Restaurant, Item |
4 | 4 | |
5 | 5 | class GenericRelationTests(TestCase): |
6 | | |
7 | 6 | def test_inherited_models_content_type(self): |
8 | 7 | """ |
9 | 8 | Test that GenericRelations on inherited classes use the correct content |
10 | 9 | type. |
11 | 10 | """ |
12 | | |
| 11 | |
13 | 12 | p = Place.objects.create(name="South Park") |
14 | | r = Restaurant.objects.create(name="Chubby's") |
| 13 | r = Restaurant.objects.create(name="Chubby's") |
15 | 14 | l1 = Link.objects.create(content_object=p) |
16 | 15 | l2 = Link.objects.create(content_object=r) |
17 | 16 | self.assertEqual(list(p.links.all()), [l1]) |
18 | 17 | self.assertEqual(list(r.links.all()), [l2]) |
19 | | |
20 | | No newline at end of file |
| 18 | |
| 19 | def test_lazy_generic_relation(self): |
| 20 | p = Item.objects.create() |
| 21 | l1 = Link() |
| 22 | p.links.add(l1) |
| 23 | p.delete() |