mirror of
https://github.com/django/django.git
synced 2025-10-30 17:16:10 +00:00
Fixed #11319 - Added lookup support for ForeignKey.to_field. Also reverted no-longer-needed model formsets workaround for lack of such support from r10756. Thanks Russell and Alex for review.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@15303 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
@@ -1364,7 +1364,12 @@ class Query(object):
|
||||
table = opts.db_table
|
||||
from_col = local_field.column
|
||||
to_col = field.column
|
||||
target = opts.pk
|
||||
# In case of a recursive FK, use the to_field for
|
||||
# reverse lookups as well
|
||||
if orig_field.model is local_field.model:
|
||||
target = opts.get_field(field.rel.field_name)
|
||||
else:
|
||||
target = opts.pk
|
||||
orig_opts._join_cache[name] = (table, from_col, to_col,
|
||||
opts, target)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user