Friday, May 13, 2011

Django flickr api encoding issue

I was having trouble with Django rendering some pages with templates that worked with most other pages. I dug into the issue, and saw a DjangoUnicodeDecodeError exception, from encoding.py, line 88.

Turns out that Django expects UTF-8 encoding by default, while the results that I was getting with the flickr api were ISO-8859-1 encoded (being that its targeted to the web), and the Django rendering engine was having a cow with that.

The fix was simple, but not one that I am really happy with. I changed the templates/__init__.py for my Django installation to call:

value = force_unicode(value,encoding='iso-8859-1')

in the _render_value_in_context() function.

Not the best way to solve the problem, so I am open to any suggestions on better ways to do this.

In my defense:
- I tried looking for somewhere in the Django settings where I would set the default encoding to ISO-8859, but could not find anything
- I was pressed for time, didnt want to go down a cleaner implementation that did not touch the base Django install


Monday, March 7, 2011

Week 9 of 2011

Every once in a while the top photos of the week scream out a theme. This week, the flickrverse was clearly enamored with the Geneva Auto Show.


From the time the Murci raced the Veyron on Top Gear Season 13, episode 2, been waiting to see the replacement. Lamborghini unveiled the Aventador at Geneva, and definitely a worthy successor - a 60 HP bump to 700 horses!  Cant wait to see the face off between the Aventador and the Veyron!

Getting back to photos - looks like we have the year's first dandelion photo! Looking forward to many more as the weather heats up in the northern hemisphere!

 My favorite for the week was this beautiful silhouette of the Great Egret - its just such a great capture of a stunningly beautiful creature!

Until the next time - keep clicking!