Django

Code

Changeset 4470

Show
Ignore:
Timestamp:
02/09/07 21:39:56 (2 years ago)
Author:
mtredinnick
Message:

Fixed #2348 -- Improved error reporting when query filter arguments are
misspelt. Variation on a patch from Karen Tracey.

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/django/db/models/query.py

    r4428 r4470  
    882882                new_column = new_opts.pk.column 
    883883                join_column = field.column 
    884  
    885             raise FieldFound 
     884                raise FieldFound 
     885            elif path: 
     886                # For regular fields, if there are still items on the path, 
     887                # an error has been made. We munge "name" so that the error 
     888                # properly identifies the cause of the problem. 
     889                name += LOOKUP_SEPARATOR + path[0] 
     890            else: 
     891                raise FieldFound 
    886892 
    887893    except FieldFound: # Match found, loop has been shortcut. 
  • django/trunk/tests/modeltests/lookup/models.py

    r4394 r4470  
    207207[<Article: Article with \ backslash>, <Article: Article% with percent sign>, <Article: Article_ with underscore>, <Article: Article 5>, <Article: Article 6>, <Article: Article 4>, <Article: Article 2>, <Article: Article 3>, <Article: Article 7>, <Article: Article 1>] 
    208208 
     209# Programming errors are pointed out with nice error messages 
     210>>> Article.objects.filter(pub_date_year='2005').count() 
     211Traceback (most recent call last): 
     212    ... 
     213TypeError: Cannot resolve keyword 'pub_date_year' into field 
     214 
     215>>> Article.objects.filter(headline__starts='Article') 
     216Traceback (most recent call last): 
     217    ... 
     218TypeError: Cannot resolve keyword 'headline__starts' into field 
     219 
    209220"""}