Mencoba aplikasi GeoDjangoLink to this heading
Included in this documentation are some additional notes and settings for PostGIS users.
PostGISLink to this heading
PengaturanLink to this heading
POSTGIS_VERSIONLink to this heading
When GeoDjango's spatial backend initializes on PostGIS, it has to perform an SQL query to determine the version in order to figure out what features are available. Advanced users wishing to prevent this additional query may set the version manually using a 3-tuple of integers specifying the major, minor, and micro version numbers for PostGIS. For example, to configure for PostGIS X.Y.Z you would use:
POSTGIS_VERSION = (X, Y, Z)
Mendapatkan hak cukupLink to this heading
Depending on your configuration, this section describes several methods to configure a database user with sufficient privileges to run tests for GeoDjango applications on PostgreSQL. If your spatial database template was created like in the instructions, then your testing database user only needs to have the ability to create databases. In other configurations, you may be required to use a database superuser.
Buat pengguna basisdataLink to this heading
Untuk membuat pengguna basisdata dengan kemampuan membuat basisdata, gunakan perintah berikut:
$ createuser --createdb -R -S <user_name>
The -R -S flags indicate that we do not want the user to have the ability
to create additional users (roles) or to be a superuser, respectively.
Alternatively, you may alter an existing user's role from the SQL shell (assuming this is done from an existing superuser account):
postgres# ALTER ROLE <user_name> CREATEDB NOSUPERUSER NOCREATEROLE;
Membuat basisdata superuserLink to this heading
Ini mungkin selesai pada waktu pengguna dibuat, sebagai contoh:
$ createuser --superuser <user_name>
Or you may alter the user's role from the SQL shell (assuming this is done from an existing superuser account):
postgres# ALTER ROLE <user_name> SUPERUSER;
WindowsLink to this heading
Pada serambi Windows peralatan pgAdmin III mungkin juga digunakan sesederhana cara untuk menambahkan hak superuser ke pengguna basisdata anda.
By default, the PostGIS installer on Windows includes a template
spatial database entitled template_postgis.
Percobaan GeoDjangoLink to this heading
To have the GeoDjango tests executed when running the Django test suite with runtests.py all of the databases in the settings
file must be using one of the spatial database backends.
ContohLink to this heading
The following is an example bare-bones settings file with spatial backends
that can be used to run the entire Django test suite, including those
in django.contrib.gis:
DATABASES = {
'default': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'geodjango',
'USER': 'geodjango',
},
'other': {
'ENGINE': 'django.contrib.gis.db.backends.postgis',
'NAME': 'other',
'USER': 'geodjango',
},
}
SECRET_KEY = 'django_tests_secret_key'
Assuming the settings above were in a postgis.py file in the same
directory as runtests.py, then all Django and GeoDjango tests would
be performed when executing the command:
$ ./runtests.py --settings=postgis
To run only the GeoDjango test suite, specify gis_tests:
$ ./runtests.py --settings=postgis gis_tests