Based on the django-countries
documentation,
>>> person.country
Country(code='NZ')
>>> person.country.name
u'New Zealand'
should be a way to retrieve the unicode for the country name. However, when I try it i get
>>> obj.country
Country(code='AX')
>>> obj.country.name
<django.utils.functional.__proxy__ object at 0x91b81ac>
I checkout out countries.py and saw that the choices look like this:
('AX', ugettext_lazy('\xc5land Islands'))
Even using print object.country.name
prints the same object. Why is it not working?
edit: Sorry, i just put the name object as a sample :p
A Django application that provides country choices for use with forms, flag icons static files, and a country field for models.
In Django, we have a third-party package called 'django-countries' that provides the country field. In this article, let's see how to use django-countries to add a Country field in Django. First, create a Django project and an app. Add the app in INSTALLED_APPS and set up urls.
https://docs.djangoproject.com/en/1.3/ref/unicode/#translated-strings
from django.utils.translation import ugettext_lazy
u = ugettext_lazy('hello')
print u
# out: <django.utils.functional.__proxy__ object at 0x158edd0>
print unicode(u)
# out: u'hello'
Normally not an issue if rendered in a template.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With