[PDB-tech] Country Code "XK"

Matt Griswold grizz at 20c.com
Thu May 5 22:10:36 PDT 2016


* "LOOS Eric (BCS/CBU)" <eric.loos at bics.com> [160506 04:59 +0000]:
> True enough, but I came across this issue when I was trying to use
> the django-peeringdb code, it relies on django_countries, which is
> using ONLY ISO approved country-codes. I did a quick hack an added XK
> to it (+ XK mapping to UNK, numeric 900) UNK = under supervision of
> united nations, 900-999: numeric range reserved for user defined
> situations.
From how I read it, using XK in this case is one of the reasons
ISO-3166 has user defined codes, specifying a new country before ISO
officially adds it. According to wikipedia, it's used by "European
Commission, Switzerland, the Deutsche Bundesbank and other
organisations."

> So our only option to make django_peeringdb work out of the box if we
> want to keep non-ISO country codes is to create a new CountryField
> from the one supplied by django_countries, which has a filter
> accepting these private ranges. The API docs do show 'XK' as a choice.
An easier way to deal with it is to add the following to your settings:

    # add user defined iso code for Kosovo
    COUNTRIES_OVERRIDE={
         'XK': _('Kosovo'),
    },

If you're not using _ for tranlastions, add:

    _ = lambda s: s

or remove _()

From https://github.com/peeringdb/peeringdb-py/blob/master/peeringdb/localdb.py#L87

We should probably add a note to that for django-peeringdb as well.


More information about the Pdb-tech mailing list