Memasang PostGISLink to this heading

PostGIS menambahkan dukungan obyek geografis pada PostgreSQL, merubah itu menjadi basisdata spasial. GEOS, PROJ dan GDAL harus dipasang sebelum membangun PostGIS. Anda mungkin juga butuh pustaka-pustaka tambahan, lihat PostGIS requirements.

Modul psycopg2 dibutuhkan untuk digunakan sebagai pencocok basisdata ketika menggunakan GeoDjango dengan PostGIS.

On Debian/Ubuntu, you are advised to install the following packages: postgresql-x, postgresql-x-postgis-3, postgresql-server-dev-x, and python3-psycopg2 (x matching the PostgreSQL version you want to install). Alternately, you can build from source. Consult the platform-specific instructions if you are on macOS or Windows.

Pasca-pemasanganLink to this heading

Membuat basisdata spasialLink to this heading

PostGIS 2 menyertakan sebuah tambahan untuk PostgreSQL yang digunakan untuk mengadakan kegunaan spasial:

Code
$ createdb  <db name>
$ psql <db name>
> CREATE EXTENSION postgis;

Pengguna basisdata harus super pengguna untuk menjalankan CREATE EXTENSION postgis;. Perintah berjalan selama pengolahan migrate. Sebuah cara lain adalah untuk menggunakan tndakan perpindahan dalam proyek anda:

Code
from django.contrib.postgres.operations import CreateExtension
from django.db import migrations

class Migration(migrations.Migration):

    operations = [
        CreateExtension('postgis'),
        ...
    ]

If you plan to use PostGIS raster functionality on PostGIS 3+, you should also activate the postgis_raster extension. You can install the extension using the CreateExtension migration operation, or directly by running CREATE EXTENSION postgis_raster;.

GeoDjango saat ini tidak mempengaruhi PostGIS topology functionality apapun. Jika anda berencana untuk menggunakan fitur-fitur tersebut pada beberapa titik, anda dapat juga memasang tambahan postgis_topology dengan menerbitkan CREATE EXTENSION postgis_topology;.

Mengelola basisdataLink to this heading

To administer the database, you can either use the pgAdmin III program (Start ‣ PostgreSQL X ‣ pgAdmin III) or the SQL Shell (Start ‣ PostgreSQL X ‣ SQL Shell). For example, to create a geodjango spatial database and user, the following may be executed from the SQL Shell as the postgres user:

Code
postgres# CREATE USER geodjango PASSWORD 'my_passwd';
postgres# CREATE DATABASE geodjango OWNER geodjango;