I'm using django-cities-light (lighter version of django-cities) with Django 1.8.x. It defines the abstract models of Country, Region/State and City, so that we can extend and add custom fields. For example, we can add timezone to city by writing a post_import signal handler as explained here.
Likewise I need to add the field
capital to each country. I'm not much familiar in GeoDjango and I knew that
django-cities app's Country has the capital field.
Best How To :
You need to setup a custom Country model. Lets say you have an app 'mygeonames' with models.py:
from django.db import models
from cities_light.settings import ICountry
from cities_light.receivers import connect_default_signals
from cities_light.abstract_models import (AbstractCountry, AbstractRegion,
capital = models.CharField(max_length=50)
def process_country_import(sender, instance, items, **kwargs):
instance.capital = items[ICountry.capital]
Then in settings.py you should specify
CITIES_LIGHT_APP_NAME = 'mygeonames', and put both apps 'cities_light' and 'mygeonames' to
After that you can migrate your DB and run
At the end you should get something like this:
In : from mygeonames.models import Country
In : cc = Country.objects.all()
In : cc.capital
But you might want to link with Cities table instead.