from django.utils.translation import ugettext as _ from django.db import models # Old: http://xml.coverpages.org/country3166.html # 2023-12-29: Updated list of countries from https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes COUNTRIES = ( ('AD', _('Andorra')), ('AE', _('United Arab Emirates')), ('AF', _('Afghanistan')), ('AG', _('Antigua & Barbuda')), ('AI', _('Anguilla')), ('AL', _('Albania')), ('AM', _('Armenia')), ('AO', _('Angola')), ('AQ', _('Antarctica')), ('AR', _('Argentina')), ('AS', _('American Samoa')), ('AT', _('Austria')), ('AU', _('Australia')), ('AW', _('Aruba')), ('AX', _('Aland Islands')), ('AZ', _('Azerbaijan')), ('BA', _('Bosnia and Herzegovina')), ('BB', _('Barbados')), ('BD', _('Bangladesh')), ('BE', _('Belgium')), ('BF', _('Burkina Faso')), ('BG', _('Bulgaria')), ('BH', _('Bahrain')), ('BI', _('Burundi')), ('BJ', _('Benin')), ('BL', _('St. Barts')), ('BM', _('Bermuda')), ('BN', _('Brunei')), ('BO', _('Bolivia')), ('BQ', _('Caribbean Netherlands')), ('BR', _('Brazil')), ('BS', _('Bahamas')), ('BT', _('Bhutan')), ('BV', _('Bouvet Island')), ('BW', _('Botswana')), ('BY', _('Belarus')), ('BZ', _('Belize')), ('CA', _('Canada')), ('CC', _('Cocos (Keeling) Islands')), ('CD', _('Congo - Kinshasa')), ('CF', _('Central African Republic')), ('CG', _('Congo - Brazzaville')), ('CH', _('Switzerland')), ('CI', _('Ivory Coast')), ('CK', _('Cook Islands')), ('CL', _('Chile')), ('CM', _('Cameroon')), ('CN', _('China')), ('CO', _('Colombia')), ('CR', _('Costa Rica')), ('CU', _('Cuba')), ('CV', _('Cape Verde')), ('CW', _('Curacao')), ('CX', _('Christmas Island')), ('CY', _('Cyprus')), ('CZ', _('Czechia')), ('DE', _('Germany')), ('DJ', _('Djibouti')), ('DK', _('Denmark')), ('DM', _('Dominica')), ('DO', _('Dominican Republic')), ('DZ', _('Algeria')), ('EC', _('Ecuador')), ('EE', _('Estonia')), ('EG', _('Egypt')), ('EH', _('Western Sahara')), ('ER', _('Eritrea')), ('ES', _('Spain')), ('ET', _('Ethiopia')), ('FI', _('Finland')), ('FJ', _('Fiji')), ('FK', _('Falkland Islands')), ('FM', _('Micronesia')), ('FO', _('Faroe Islands')), ('FR', _('France')), ('GA', _('Gabon')), ('GB', _('United Kingdom')), ('GD', _('Grenada')), ('GE', _('Georgia')), ('GF', _('French Guiana')), ('GG', _('Guernsey')), ('GH', _('Ghana')), ('GI', _('Gibraltar')), ('GL', _('Greenland')), ('GM', _('Gambia')), ('GN', _('Guinea')), ('GP', _('Guadeloupe')), ('GQ', _('Equatorial Guinea')), ('GR', _('Greece')), ('GS', _('South Georgia and the South Sandwich Islands')), ('GT', _('Guatemala')), ('GU', _('Guam')), ('GW', _('Guinea-Bissau')), ('GY', _('Guyana')), ('HK', _('Hong Kong SAR China')), ('HM', _('Heard & McDonald Islands')), ('HN', _('Honduras')), ('HR', _('Croatia')), ('HT', _('Haiti')), ('HU', _('Hungary')), ('ID', _('Indonesia')), ('IE', _('Ireland')), ('IL', _('Israel')), ('IM', _('Isle of Man')), ('IN', _('India')), ('IO', _('British Indian Ocean Territory')), ('IQ', _('Iraq')), ('IR', _('Iran')), ('IS', _('Iceland')), ('IT', _('Italy')), ('JE', _('Jersey')), ('JM', _('Jamaica')), ('JO', _('Jordan')), ('JP', _('Japan')), ('KE', _('Kenya')), ('KG', _('Kyrgyzstan')), ('KH', _('Cambodia')), ('KI', _('Kiribati')), ('KM', _('Comoros')), ('KN', _('St. Kitts and Nevis')), ('KP', _('North Korea')), ('KR', _('South Korea')), ('KW', _('Kuwait')), ('KY', _('Cayman Islands')), ('KZ', _('Kazakhstan')), ('LA', _('Laos')), ('LB', _('Lebanon')), ('LC', _('St. Lucia')), ('LI', _('Liechtenstein')), ('LK', _('Sri Lanka')), ('LR', _('Liberia')), ('LS', _('Lesotho')), ('LT', _('Lithuania')), ('LU', _('Luxembourg')), ('LV', _('Latvia')), ('LY', _('Libya')), ('MA', _('Morocco')), ('MC', _('Monaco')), ('MD', _('Moldova')), ('ME', _('Montenegro')), ('MF', _('St. Martin')), ('MG', _('Madagascar')), ('MH', _('Marshall Islands')), ('MK', _('North Macedonia')), ('ML', _('Mali')), ('MM', _('Myanmar (Burma)')), ('MN', _('Mongolia')), ('MO', _('Macao SAR China')), ('MP', _('Northern Mariana Islands')), ('MQ', _('Martinique')), ('MR', _('Mauritania')), ('MS', _('Montserrat')), ('MT', _('Malta')), ('MU', _('Mauritius')), ('MV', _('Maldives')), ('MW', _('Malawi')), ('MX', _('Mexico')), ('MY', _('Malaysia')), ('MZ', _('Mozambique')), ('NA', _('Namibia')), ('NC', _('New Caledonia')), ('NE', _('Niger')), ('NF', _('Norfolk Island')), ('NG', _('Nigeria')), ('NI', _('Nicaragua')), ('NL', _('Netherlands')), ('NO', _('Norway')), ('NP', _('Nepal')), ('NR', _('Nauru')), ('NU', _('Niue')), ('NZ', _('New Zealand')), ('OM', _('Oman')), ('PA', _('Panama')), ('PE', _('Peru')), ('PF', _('French Polynesia')), ('PG', _('Papua New Guinea')), ('PH', _('Philippines')), ('PK', _('Pakistan')), ('PL', _('Poland')), ('PM', _('St. Pierre & Miquelon')), ('PN', _('Pitcairn Islands')), ('PR', _('Puerto Rico')), ('PS', _('Palestinian Territories')), ('PT', _('Portugal')), ('PW', _('Palau')), ('PY', _('Paraguay')), ('QA', _('Qatar')), ('RE', _('Reunion')), ('RO', _('Romania')), ('RS', _('Serbia')), ('RU', _('Russia')), ('RW', _('Rwanda')), ('SA', _('Saudi Arabia')), ('SB', _('Solomon Islands')), ('SC', _('Seychelles')), ('SD', _('Sudan')), ('SE', _('Sweden')), ('SG', _('Singapore')), ('SH', _('St. Helena')), ('SI', _('Slovenia')), ('SJ', _('Svalbard and Jan Mayen')), ('SK', _('Slovakia')), ('SL', _('Sierra Leone')), ('SM', _('San Marino')), ('SN', _('Senegal')), ('SO', _('Somalia')), ('SR', _('Suriname')), ('SS', _('South Sudan')), ('ST', _('Sao Tome & Principe')), ('SV', _('El Salvador')), ('SX', _('Sint Maarten')), ('SY', _('Syria')), ('SZ', _('Eswatini')), ('TC', _('Turks & Caicos Islands')), ('TD', _('Chad')), ('TF', _('French Southern Territories')), ('TG', _('Togo')), ('TH', _('Thailand')), ('TJ', _('Tajikistan')), ('TK', _('Tokelau')), ('TL', _('Timor-Leste')), ('TM', _('Turkmenistan')), ('TN', _('Tunisia')), ('TO', _('Tonga')), ('TR', _('Turkey')), ('TT', _('Trinidad & Tobago')), ('TV', _('Tuvalu')), ('TW', _('Taiwan')), ('TZ', _('Tanzania')), ('UA', _('Ukraine')), ('UG', _('Uganda')), ('UM', _('U.S. Outlying Islands')), ('US', _('United States')), ('UY', _('Uruguay')), ('UZ', _('Uzbekistan')), ('VA', _('Vatican City')), ('VC', _('St. Vincent & Grenadines')), ('VE', _('Venezuela')), ('VG', _('British Virgin Islands')), ('VI', _('U.S. Virgin Islands')), ('VN', _('Vietnam')), ('VU', _('Vanuatu')), ('WF', _('Wallis & Futuna')), ('WS', _('Samoa')), ('YE', _('Yemen')), ('YT', _('Mayotte')), ('ZA', _('South Africa')), ('ZM', _('Zambia')), ('ZW', _('Zimbabwe')), ) class CountryField(models.CharField): def __init__(self, *args, **kwargs): kwargs.setdefault('choices', COUNTRIES) kwargs.setdefault('default', 'CH') kwargs.setdefault('max_length', 2) super(CountryField, self).__init__(*args, **kwargs) def get_internal_type(self): return "CharField"