Fix bugs introduced by transition django 1.4.x -> 1.5.x.

Change-Id: Ib84cb41260062285d59748fdc5f210aeca06798e
Closes-bug: #1248503