diff --git a/tests/modeltests/custom_pk/models.py b/tests/modeltests/custom_pk/models.py
index b88af16..a4b0fea 100644
a
|
b
|
DoesNotExist: Employee matching query does not exist.
|
133 | 133 | ... print "Fail with %s" % type(e) |
134 | 134 | Pass |
135 | 135 | |
136 | | # Regression for #10785 -- Custom fields can be used for primary keys. |
| 136 | # Regression for #10785, #11319 -- Custom fields can be used for primary keys. |
137 | 137 | >>> new_bar = Bar.objects.create() |
138 | 138 | >>> new_foo = Foo.objects.create(bar=new_bar) |
139 | 139 | |
140 | | # FIXME: This still doesn't work, but will require some changes in |
141 | | # get_db_prep_lookup to fix it. |
142 | | # >>> f = Foo.objects.get(bar=new_bar.pk) |
143 | | # >>> f == new_foo |
144 | | # True |
145 | | # >>> f.bar == new_bar |
146 | | # True |
| 140 | >>> f = Foo.objects.get(bar=new_bar.pk) |
| 141 | >>> f == new_foo |
| 142 | True |
| 143 | >>> f.bar == new_bar |
| 144 | True |
147 | 145 | |
148 | 146 | >>> f = Foo.objects.get(bar=new_bar) |
149 | 147 | >>> f == new_foo |
diff --git a/tests/regressiontests/queries/models.py b/tests/regressiontests/queries/models.py
index 0d28926..2525530 100644
a
|
b
|
class Plaything(models.Model):
|
271 | 271 | def __unicode__(self): |
272 | 272 | return self.name |
273 | 273 | |
| 274 | # Recursive ForeignKey using "to_field". |
| 275 | class Node(models.Model): |
| 276 | num = models.IntegerField(unique=True) |
| 277 | parent = models.ForeignKey("self", to_field="num", null=True) |
| 278 | |
| 279 | def __unicode__(self): |
| 280 | return unicode(self.num) |
274 | 281 | |
275 | 282 | __test__ = {'API_TESTS':""" |
276 | 283 | >>> generic = NamedCategory.objects.create(name="Generic") |
… |
… |
True
|
1173 | 1180 | >>> subq._result_cache is None |
1174 | 1181 | True |
1175 | 1182 | |
| 1183 | Filtering against a related object must use the to_field value, if it exists, |
| 1184 | not the pk (bug #11319). |
| 1185 | >>> a1 = Author.objects.get(name="a1") |
| 1186 | >>> Report.objects.filter(creator=a1) |
| 1187 | [<Report: r1>] |
| 1188 | >>> Author.objects.filter(report=r1) |
| 1189 | [<Author: a1>] |
| 1190 | |
| 1191 | >>> node1 = Node.objects.create(num=42) |
| 1192 | >>> node2 = Node.objects.create(num=1, parent=node1) |
| 1193 | >>> Node.objects.filter(node=node2).query.as_sql() |
| 1194 | >>> Node.objects.filter(node=node2) |
| 1195 | [<Node: 42>] |
| 1196 | >>> Node.objects.filter(parent=node1) |
| 1197 | [<Node: 1>] |
| 1198 | |
1176 | 1199 | """} |
1177 | 1200 | |
1178 | 1201 | # In Python 2.3 and the Python 2.6 beta releases, exceptions raised in __len__ |
… |
… |
Using an empty generator expression as the rvalue for an "__in" lookup is legal
|
1241 | 1264 | [] |
1242 | 1265 | |
1243 | 1266 | """ |
| 1267 | |