Package: django-international
django-international is a combination of data, models, and forms, for handling
country- and currency-related information in yourDjangoproject. The data
used in this app comes fromWikipediaandXE.com, and will be updated from
time to time when sources become updated.Language name data is acquired frombabelif babel is installed.Contentsinternational.models.countries_rawinternational.models.countriesinternational.models.currenciesinternational.models.languagesinternationa.models.languages_nativeinternational.models.languages_englishinternational.models.CountryCountry.codeCountry.continentinternational.forms.CountryForminternational.forms.CurrencyForminternational.forms.CountryCurrencyFormFixturesContributorsReporting bugsinternational.models.countries_rawThis is a tuple of tuples in the following format:countries_raw = (
    (CO, CC, CNT, NUM, FN),
    ...
)COis the two-letter continent code.CCis the country code as per ISO
3166-1 standard.CNTis the 3-letter code as per ISO 3166-1 standard.NUMis the three-digit code as per ISO-3166-1 standard.FNis the full name of
the country as a translatable string (wrapped indjango.util.translation.ugettext).This tuple is processed at runtime to derive the choices-compatible tuple.Please note that some country names were modified and that the choices tuple
will omit anything that appears in brackets compared to the original list onWikipedia.international.models.countriesThis is a tuple of tuples compatible withchoicesargument passed to
Django’s model/form fields. The values are 2-letter country codes, and display
values are full country names without the parts that appear in brackets.This tuple is also used as choices argument in the country form ifuse_staticargument is passed to the constructor, orCOUNTRY_FORM_USE_STATICconfiguration setting is set toTrue.international.models.currenciesThis is atuple of tuples compatible withchoicesargument passed to
Django’s model/form fields. The values are ISO 4217 3-letter currency codes,
and display values are the same codes with full currency names. For example:('USD', 'USD - United States Dollar')This tuple is used aschoicesargument for theChoicesFieldin the
currency form.international.models.languagesThis list provides a list of choices-compatible tuples that pair locale
identifiers (e.g.,'en_US') with both native and English language names of
the language. For languages whose native names are in English, no translation
is used. E.g.:jp          日本語 (Japanese)
en_US       U.S. EnglishThis list is empty if babel is not installed, but having babel installed isnota requirement if you do not need language lists.internationa.models.languages_nativeSame asinternational.models.langaugesbut using only native version of the
name as label. As with other language lists, this list is only populated if
babel is installed.international.models.languages_englishSame asinternational.models.langaugesbut using only English version of
the name as label. AS with other language lists, this is only populated if
babel is installed.international.models.CountryThemodelsmodule contains aCountrymodel. It is a full model (not
abstract) and it is meant to be linked to from your other modules via foreign
keys.Country.codeThis field contains 2-letter ISO code for your country as per ISO 3166-1 alpha
2 standard. The field is constrained by choices which allows a full set of
countries found onWikipedia. There is currently no way of restricting the
choices with configuration settings.The full names of countries are translatable strings, and can be displayed by
using the standard Django API for display names:>>> c = Country(code='AR', continent='SA')
>>> c.get_code_display()
u'Argentina'Country.continentThis field contains two-letter codes for continents as perWikipedia. These
are restricted to:AF–  AfricaAS–  AsiaEU–  EuropeNA–  North AmericaSA–  South AmericaOC–  OceaniaAN–  AntarcticaThe full names are translatable, and can be obtained using Django’s standard
display name API:>>> c = Country(code='AR', continent='SA')
>>> c.get_continent_display()
u'South America'international.forms.CountryFormThe contstructor is invoked usual form arguments and some addional arguments:CountryForm(*arg,
            use_static=False,
            include_empty=False,
            empty_value='',
            empty_label='All countries',
            **kwarg)This is a simple form with a singleChoiceFieldfield calledcountry.
It is marked as optional, has a translatable label that reads ‘country’, and
has empty string as initial value.Some aspects of this form can be controlled using configuration settings or
constructor arguments. Any arguments that a standard Django form accepts are
also acceptable (e.g.,initialordata). Note that constructor
arguments always take precedence over settings.Following sections describe available configuration settings and matching
constructor arguments.COUNTRY_FORM_USE_STATICoruse_staticThese options control whether to use thecountriestuple or use
existing countries from theCountrymodel as choices for the field. If
the model objects are used, they are read from the database each time the
form is initialized. There is currently no caching involved.COUNTRY_FORM_INCLUDE_EMPTYorinclude_emptyWhether to include an ‘empty’ item in the choices. This can be treated as aNonevalue in the views, depending on your needs. If set toTrue, a
single two-tuple will be prepended to the choices tuple that uses empty
value specified byCOUNTRY_FORM_EMPTY_VALUEsetting or theempty_valueconstructor argument, and label matching theCOUNTRY_FORM_EMPTY_LABELsetting orempty_labelconstructor
argument.COUNTRY_FORM_EMPTY_VALUEorempty_valueThe value to use as empty. Defaults to empty string.COUNTRY_FORM_EMPTY_LABELorempty_labelValue to use as display value for the empty item. Default to a translatable
string ‘All countries’.international.forms.CurrencyFormJust likeCountryForm(q.v.,international.forms.CountryForm),CurrencyFormcan be invoked with additonal arguments:CurrencyForm(*arg,
             include_empty=False,
             empty_value='',
             empty_label='All currencies',
             **kwarg)Simple form with a simpleChoiceFieldfield calledcurrency. It uses
thecurrenciestuple as choices argument.This form has similar configuration parameters as theCountryFormform.CURRENCY_FORM_INCLUDE_EMPTYorinclude_emptyWhether to include an empty item in the choices. The value and label of the
empty item are controlled via theCURRENCY_FORM_EMPTY_VALUEandCURRENCY_FORM_EMPTY_LABELsettings, or theempty_valueandempty_labelconstructor arguments.CURRENCY_FORM_EMPTY_VALUEorempty_valueControls the empty item’s value. Defaults to ‘’.CURRENCY_FORM_EMPTY_LABELorempty_labelControls the label used for the empty item. Defaults to a translatable string
‘All currencies’.international.forms.CountryCurrencyFormThis is an experimental feature that combines both theCountryFormandCurrencyForminto a single form. This form is governed by both sets of
settings and constructor arguments that apply to either of the simple forms.This feature hsan’t been tested thoroughly (especially the constructor
arguments), but it is known to work as expected with configuration settings.Also seeinternational.forms.CountryFormandinternational.forms.CurrencyFormfor more information.FixturesTheinternational/fixtures/directory contains a set of fixtures that can
be loaded using theloaddatamanagement command. The fixtures are generated
based oncountries_rawtuple, and contains the data for theCountrymodel. It is intentionally not the initial data fixture, since the purpose of
theCountrymodel is to create an editable list of countries, and not have
them hard-coded. Initial data fixture would overwrite the data each timesyncdbcommand is used, so it would effectively invalidate the very purpose
of the model.ContributorsTheo Chatzimichos (https://bitbucket.org/tampakrap)Reporting bugsBugs can be reported to Bitbucketissue tracker.