Dec 28

'unicode' object has no attribute 'get_sql'

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.

Comments

1 ugg boots shoes says...

Ugg boots shoes <a href= http://www.uggsmall.com>Ugg boots shoes</a> five finger shoes <a href= http://www.acevibram.com/>five finger shoes</a> Uggs outlet <a href= http://www.uggsmall.com>Uggs outlet</a> cheap ugg boots <a href= http://www.uggsmall.com>cheap ugg boots</a> Ugg on sale <a href= http://www.uggsmall.com>Uggs on sale</a> Uggs australia <a href= http://www.uggsmall.com>Uggs australia</a> ugg bailey button boots <a href= http://www.uggsmall.com/ugg-bailey-button-boots-c-19.html... bailey button boots</a> ugg classic cardy boots <a href= http://www.uggsmall.com/ugg-classic-cardy-boots-c-2.html>ugg classic cardy boots</a> ugg nightfall boots <a href= http://www.uggsmall.com/ugg-nightfall-boots-c-4.html>ugg nightfall boots</a> ugg sundance ii boots <a href= http://www.uggsmall.com/ugg-sundance-ii-boots-c-5.html>ugg sundance ii boots</a> ugg classic mini boots <a href= http://www.uggsmall.com/ugg-classic-mini-boots-c-6.html>ugg classic mini boots</a> ugg kids boots <a href= http://www.uggsmall.com/ugg-kids-boots-c-20.html>ugg kids boots</a>

Posted at 4:05 a.m. on July 31, 2010

2 jessie says...

Well, thanks for sharing us the wonderful code! http://www.astrabeds.com/latex-mattresses.html

Posted at 9:31 a.m. on July 31, 2010

3 latex mattress says...

Well, thank you a lot! Eventually I know what is wrong about the code!!!

Posted at 9:37 a.m. on July 31, 2010

This won't be published anywhere, it's just in case I need to contact you.

You can use Markdown in your comments. Be sensible!

Sorry about this, but I don't want spam comments.