Ticket #6639: query_patch.diff

File query_patch.diff, 1.1 KB (added by dfrishberg <dfrishberg@…>, 17 years ago)
  • Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/site-packages/django/db/models/query.py

     
    10231022            if field.rel: # One-to-One/Many-to-one field
    10241023                new_table = current_table + '__' + name
    10251024                new_opts = field.rel.to._meta
    1026                 new_column = new_opts.pk.column
     1025                if hasattr(field.rel, 'field_name'):
     1026                    to_fields = field.rel.to._meta.fields
     1027                    to_fields_names = map(lambda x: x.name, to_fields)
     1028                    new_column = to_fields[to_fields_names.index(field.rel.field_name)].db_column
     1029                else:
     1030                    new_column = new_opts.pk.column
    10271031                join_column = field.column
    10281032                raise FieldFound
    10291033            elif path:
Back to Top