Ticket #7823: 7823.2.experimental.diff
File 7823.2.experimental.diff, 1.2 KB (added by , 16 years ago) |
---|
-
django/db/models/fields/related.py
125 125 # that object. In certain conditions (especially one-to-one relations), 126 126 # the primary key may itself be an object - so we need to keep drilling 127 127 # down until we hit a value that can be used for a comparison. 128 v = value128 v, field = value, None 129 129 try: 130 130 while True: 131 v = getattr(v, v._meta.pk.name)131 v, field = getattr(v, v._meta.pk.name), v._meta.pk 132 132 except AttributeError: 133 133 pass 134 if field: 135 v = field.get_db_prep_lookup('exact', v)[0] 134 136 return v 135 137 136 138 if hasattr(value, 'as_sql'): … … 138 140 return QueryWrapper(('(%s)' % sql), params) 139 141 if lookup_type == 'exact': 140 142 return [pk_trace(value)] 141 if lookup_type == 'in':143 if lookup_type in ('range', 'in'): 142 144 return [pk_trace(v) for v in value] 143 145 elif lookup_type == 'isnull': 144 146 return []