Search code examples
djangodjango-countries

Django countries adding cities to top of list


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.


Solution

  • 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.