﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
2348	[patch] Unbound local error when performing invalid query	cmgreen@…	Adrian Holovaty	"When performing a model query with an invalid keyword, I get an UnboundLocalError rather than an error message saying it didn't know how to perform that type of query.  I lost a bit of time trying to figure out how to debug this error but it was simplistic once I figured it out.

I used equals rather than exact

{{{
   One.objects.filter(name__equals=1) 
}}}

{{{
sw/lib/python2.4/site-packages/django/db/models/query.py in lookup_inner(path, lookup_type, value, opts, table, column)
    845     if path:
    846         # There are elements left in the path. More joins are required.
--> 847         if len(path) == 1 and path[0] in (new_opts.pk.name, None) \
    848             and lookup_type in ('exact', 'isnull') and not join_required:
    849             # If the next and final name query is for a primary key,

UnboundLocalError: local variable 'new_opts' referenced before assignment
Out[22]: 
In [23]: One.objects.filter(name__equals=1)                                  
}}}
 "	defect	closed	Database layer (models, ORM)	dev	minor	fixed		kmtracey@…	Ready for checkin	1	0	0	0	0	0
