Reputation: 4316
I am using the GeoDjango
example with the class WorldBorder
.
My trouble is that I can't print out the name of the selected countries. When I try to execute
from django.utils.translation import ugettext_lazy as _
...
location = fromstr(... , srid=4326)
country = WorldBorder.objects.get(mpoly__intersects=location)
print _('User country determined to %s') %country.name
i get the error message:
Python: TypeError: 'unicode' object is not callable
When I remove the ugettext_lazy
, everything works fine. How can I keep the translation option and make the string work?
Upvotes: 1
Views: 1204
Reputation: 2961
It looks like you're using a Python shell. There, _ will take the value of the last expression evaluated. So _ ends up being the WorldBorder instance after your third line. To avoid this problem, when you're playing with translate in a shell, alias ugettext_lazy to something other than '_'.
Upvotes: 5