Code

Ticket #16455: 16455-v6.diff

File 16455-v6.diff, 3.9 KB (added by fcurella, 2 years ago)
Line 
1diff --git a/django/contrib/gis/db/backends/postgis/creation.py b/django/contrib/gis/db/backends/postgis/creation.py
2index bad22be..f806bc9 100644
3--- a/django/contrib/gis/db/backends/postgis/creation.py
4+++ b/django/contrib/gis/db/backends/postgis/creation.py
5@@ -38,12 +38,15 @@ class PostGISCreation(DatabaseCreation):
6                                   style.SQL_FIELD(qn(f.column)) +
7                                   style.SQL_KEYWORD(' SET NOT NULL') + ';')
8 
9-
10             if f.spatial_index:
11                 # Spatial indexes created the same way for both Geometry and
12                 # Geography columns
13                 if f.geography:
14                     index_opts = ''
15+                # PostGIS 2.0 does not support GIST_GEOMETRY_OPS.
16+                # Use gist_geometry_ops_nd instead.
17+                elif self.connection.ops.spatial_version >= (2, 0):
18+                    index_opts = ' ' + style.SQL_KEYWORD('gist_geometry_ops_nd')
19                 else:
20                     index_opts = ' ' + style.SQL_KEYWORD(self.geom_index_opts)
21                 output.append(style.SQL_KEYWORD('CREATE INDEX ') +
22diff --git a/docs/ref/contrib/gis/install.txt b/docs/ref/contrib/gis/install.txt
23index 72bd72a..7d237ee 100644
24--- a/docs/ref/contrib/gis/install.txt
25+++ b/docs/ref/contrib/gis/install.txt
26@@ -83,7 +83,7 @@ Program                   Description                           Required
27 `PROJ.4`_                 Cartographic Projections library      Yes (PostgreSQL and SQLite only)  4.7, 4.6, 4.5, 4.4
28 :ref:`GDAL <ref-gdal>`    Geospatial Data Abstraction Library   No (but, required for SQLite)     1.9, 1.8, 1.7, 1.6, 1.5
29 :ref:`GeoIP <ref-geoip>`  IP-based geolocation library          No                                1.4
30-`PostGIS`__               Spatial extensions for PostgreSQL     Yes (PostgreSQL only)             1.5, 1.4, 1.3
31+`PostGIS`__               Spatial extensions for PostgreSQL     Yes (PostgreSQL only)             2.0, 1.5, 1.4, 1.3
32 `SpatiaLite`__            Spatial extensions for SQLite         Yes (SQLite only)                 3.0, 2.4, 2.3
33 ========================  ====================================  ================================  ==========================
34 
35@@ -239,9 +239,9 @@ installed prior to building PostGIS.
36 
37 First download the source archive, and extract::
38 
39-    $ wget http://postgis.refractions.net/download/postgis-1.5.2.tar.gz
40-    $ tar xzf postgis-1.5.2.tar.gz
41-    $ cd postgis-1.5.2
42+    $ wget http://postgis.refractions.net/download/postgis-2.0.1.tar.gz
43+    $ tar xzf postgis-2.0.1.tar.gz
44+    $ cd postgis-2.0.1
45 
46 Next, configure, make and install PostGIS::
47 
48@@ -255,8 +255,9 @@ Finally, make and install::
49 
50 .. note::
51 
52-    GeoDjango does not automatically create a spatial database.  Please
53-    consult the section on :ref:`spatialdb_template` for more information.
54+    If you are running a version of PostgreSQL earlier than 9.1: GeoDjango does
55+    not automatically create a spatial database.  Please consult the section on
56+    :ref:`spatialdb_template` for more information.
57 
58 __ http://postgis.refractions.net/
59 
60@@ -502,11 +503,25 @@ to build and install::
61 Post-installation
62 =================
63 
64+Creating a spatial database with PostGIS 2.0 and PostgreSQL 9.1
65+------------------------------------------------
66+
67+PostGIS 2 includes an extension for Postgres 9.1 that can be used to enable
68+spatial functionality.
69+
70+    $ createdb  <db name>
71+    $ psql <db name>
72+    > CREATE EXTENSION postgis;
73+    > CREATE EXTENSION postgis_topology;
74+
75 .. _spatialdb_template:
76 
77 Creating a spatial database template for PostGIS
78 ------------------------------------------------
79 
80+If you have an earlier version of PostGIS or PostgreSQL, you will need to create
81+a spatial database.
82+
83 Creating a spatial database with PostGIS is different than normal because
84 additional SQL must be loaded to enable spatial functionality.  Because of
85 the steps in this process, it's better to create a database template that