Ticket #7823: 7823.diff
File 7823.diff, 994 bytes (added by , 16 years ago) |
---|
-
django/db/models/fields/related.py
134 134 # that object. In certain conditions (especially one-to-one relations), 135 135 # the primary key may itself be an object - so we need to keep drilling 136 136 # down until we hit a value that can be used for a comparison. 137 v = value137 v, field = value, None 138 138 try: 139 139 while True: 140 v = getattr(v, v._meta.pk.name)140 v, field = getattr(v, v._meta.pk.name), v._meta.pk 141 141 except AttributeError: 142 142 pass 143 if field: 144 v = field.get_db_prep_lookup(lookup_type, v) 145 if isinstance(v, list): 146 v = v[0] 143 147 return v 144 148 145 149 if hasattr(value, 'as_sql'):