Fixing code according to data returned by django