Using IDLE or another IDE, open settings.py from the chapter12 project folder. Scroll down to the variable called DATABASES. This variable, which is set to a local SQLite database, will be adjusted to the PostgreSQL database with the PostGIS extension.
This is the default:
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
Change it to the following, substituting the username and password for your PostGIS installation (see Chapter 3, Introduction to Geospatial Databases):
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'chapter12',
'USER': '{username}',
'PASSWORD': '{password}',
'HOST': '127.0.0.1',
'PORT':'5432'
},
}
An empty string can also be used for the HOST option to indicate localhost. If the PostgreSQL installation is on a different machine, adjust the HOST option to the IP address of the database server. If it is on a different port, adjust the PORT option.
Save the script, but don't close it.