Rick Graves
Rick Graves

Reputation: 607

Django CountryField COUNTRIES_OVERRIDE & COUNTRIES_FIRST -- NOT WORKING

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.

Upvotes: 0

Views: 687

Answers (1)

Alasdair
Alasdair

Reputation: 308949

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' }

Upvotes: 2

Related Questions