mirror of
https://github.com/django/django.git
synced 2025-12-02 00:01:29 +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:
parent
7c888a7aa9
commit
227c5e80db
8 changed files with 122 additions and 14 deletions
|
|
@ -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)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue