SmileyChris / django-countries

A Django application that provides country choices for use with forms, flag icons static files, and a country field for models.

Home Page:https://pypi.python.org/pypi/django-countries

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Store multiple countries sorted to DB

jedie opened this issue · comments

The countries should be stored ordered. So low level database lookups can be easier made.

As a work-a-round is to use permutations e.g.:

gas_countries = list(','.join(codes) for codes in permutations(['DE', 'AT', 'CH']))
MyModel.objects.exclude(countries__in=gas_countries).update(countries='AT,CH,DE')

A other example: Create a Admin change list filter by countries results in permutations ;)