Changeset 3248
- Timestamp:
- 06/30/06 22:14:33 (2 years ago)
- Files:
-
- django/trunk/django/db/models/query.py (modified) (2 diffs)
- django/trunk/tests/modeltests/many_to_one/models.py (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/django/db/models/query.py
r3246 r3248 11 11 from sets import Set as set 12 12 13 # The string constant used to separate query parts 13 14 LOOKUP_SEPARATOR = '__' 15 16 # The list of valid query types 17 QUERY_TERMS=( 18 'exact', 'iexact', 19 'contains', 'icontains', 20 'gt', 'gte', 'lt', 'lte', 21 'in', 22 'startswith', 'istartswith', 'endswith', 'iendswith', 23 'range', 'year', 'month', 'day', 24 'isnull' 25 ) 14 26 15 27 # Size of each "chunk" for get_iterator calls. … … 711 723 # a dummy name of None, which we will replace when 712 724 # we know which table column to grab as the primary key. 713 # 2) If there is only one part, assume it to be an __exact 725 # 2) If there is only one part, or the last part is not a query 726 # term, assume that the query is an __exact 714 727 clause = path.pop() 715 728 if clause == 'pk': 716 729 clause = 'exact' 717 730 path.append(None) 718 elif len(path) == 0 :731 elif len(path) == 0 or clause not in QUERY_TERMS: 719 732 path.append(clause) 720 733 clause = 'exact' django/trunk/tests/modeltests/many_to_one/models.py
r3246 r3248 137 137 [<Article: John's second story>, <Article: This is a test>] 138 138 139 # Check that implied __exact also works 140 >>> Article.objects.filter(reporter__first_name='John') 141 [<Article: John's second story>, <Article: This is a test>] 142 139 143 # Query twice over the related field. 140 144 >>> Article.objects.filter(reporter__first_name__exact='John', reporter__last_name__exact='Smith') … … 236 240 [<Reporter: John Smith>] 237 241 >>> Reporter.objects.filter(article__reporter__exact=r).distinct() 242 [<Reporter: John Smith>] 243 244 # Check that implied __exact also works 245 >>> Reporter.objects.filter(article__reporter=r).distinct() 238 246 [<Reporter: John Smith>] 239 247
