Ticket #1305: django.reverse_lookup.patch
File django.reverse_lookup.patch, 735 bytes (added by , 19 years ago) |
---|
-
django/db/models/query.py
239 239 Finds a field with a specific name in a list of field instances. 240 240 Returns None if there are no matches, or several matches. 241 241 """ 242 matches = [f for f in field_list if f.name == name] 242 matches = [] 243 for f in field_list: 244 if hasattr(f, 'field') and f.field.rel.related_name: 245 if f.field.rel.related_name == name: 246 matches.append(f) 247 elif f.name == name: 248 matches.append(f) 243 249 if len(matches) != 1: 244 250 return None 245 251 return matches[0]