Using django-countries
which works as expected with django, is it possible to add a list of cities to the top of the countries list, instead of getting all the countries and populating a new country model.
Asked
Active
Viewed 419 times
1

Sam B.
- 2,703
- 8
- 40
- 78
1 Answers
1
You can't replace the country object, and really, this isn't meant to be mixed with cities, you should create your own model and implement your own logic.
If you do want to add/override the countries list you can do this, in your setup file:
COUNTRIES_OVERRIDE = {
'NZ': _('Middle Earth'),
'AU': None
}
This will define new countries, you can read more about it in the Customization section in the readme of the package.

Or Duan
- 13,142
- 6
- 60
- 65
-
It's possible to then using this create a model than identifies instance as city or country (can be a choice field with integers 0, 1) then sort by that then alphabetic – Sam B. Feb 08 '17 at 08:53
-
1It will work, but you want to make sure you separate your logic for future changes. If one day you will want to add foreign key from the `City` to `Region` you will have to add it also to the `Country` model(Since they will be in the same table) - might be a huge waste. – Or Duan Feb 08 '17 at 08:56
-
going to keep it simple just a charfield with either a digit or text to categorize category if there comes a need to link that to a region and/or country I can add a separate foreign model. – Sam B. Feb 08 '17 at 09:34