0

CountryField is working, but "United States of America" is too long, I prefer just "United States" or even "USA".

Also, I want USA & GB at the top of the list when you pull down the pull down.

When I first implemented COUNTRIES_OVERRIDE & COUNTRIES_FIRST, they were working. Then suddenly they stopped working, and have not worked since.

I have been pulling my hair out! (Not literally.)

In the models.py file where I import CountryField, I also import settings from django_countries.conf. Below the import lines, and above the model defintion that uses CountryField, I have these lines:

settings.COUNTRIES_FIRST = [ 'US', 'GB' ]
settings.COUNTRIES_OVERRIDE = { 'US': 'USA' }

Troubleshooting tips would be appreciated.

Rick Graves
  • 517
  • 5
  • 11

1 Answers1

2

You can’t reliably alter settings from other modules. Remove those lines from your models.py, and set the values in your settings.py:

COUNTRIES_FIRST = [ 'US', 'GB' ]
COUNTRIES_OVERRIDE = { 'US': 'USA' }
Alasdair
  • 298,606
  • 55
  • 578
  • 516
  • Ah! Moving the code to my settings file solved the problem. Thanks, – Rick Graves Jan 27 '18 at 04:24
  • to set an initial default value along with a default country flag check out : https://stackoverflow.com/questions/11563354/django-countries-dropdown-default – Aseem Sep 23 '18 at 09:23