'unicode' object has no attribute 'get_sql'
by
Dan Fairs
—
last modified
Dec 28, 2007 10:31 PM
I keep getting this error, and it always takes a moment of head-scratching to figure out what's wrong. Here's what's wrong, to save you some hair.
Another tiny snippet for you.
You fire up your Django app, only to be confronted with:
AttributeError at /highwire/projects/1/tasks/add/
'unicode' object has no attribute 'get_sql'
You've probably got a line like this:
foo = get_object_or_404(Foo, foo_id)
get_object_or_404() actually requires key/value pairs after the first class argument, in the same way the .filter() method does.
The code above should actually read:
foo = get_object_or_404(Foo, pk=foo_id)
It's the simple things that eat the most time.
