### Eclipse Workspace Patch 1.0
#P django-trunk
Index: django/contrib/gis/db/backends/postgis/creation.py
===================================================================
--- django/contrib/gis/db/backends/postgis/creation.py	(Revision 16722)
+++ django/contrib/gis/db/backends/postgis/creation.py	(Arbeitskopie)
@@ -10,7 +10,9 @@
         from django.contrib.gis.db.models.fields import GeometryField
 
         output = super(PostGISCreation, self).sql_indexes_for_field(model, f, style)
-
+        
+        postgis_version = self.connection.introspection.get_postgis_version()
+        
         if isinstance(f, GeometryField):
             gqn = self.connection.ops.geo_quote_name
             qn = self.connection.ops.quote_name
@@ -45,7 +47,12 @@
                 if f.geography:
                     index_opts = ''
                 else:
-                    index_opts = ' ' + style.SQL_KEYWORD(self.geom_index_opts)
+                    # Check for PostGIS Version
+                    # PostGIS 2.0 does not support GIST_GEOMETRY_OPS
+                    if postgis_version >= (2, 0):
+                        index_opts = ''
+                    else:
+                        index_opts = ' ' + style.SQL_KEYWORD(self.geom_index_opts)
                 output.append(style.SQL_KEYWORD('CREATE INDEX ') +
                               style.SQL_TABLE(qn('%s_%s_id' % (db_table, f.column))) +
                               style.SQL_KEYWORD(' ON ') +
Index: django/contrib/gis/db/backends/postgis/introspection.py
===================================================================
--- django/contrib/gis/db/backends/postgis/introspection.py	(Revision 16722)
+++ django/contrib/gis/db/backends/postgis/introspection.py	(Arbeitskopie)
@@ -93,3 +93,25 @@
             cursor.close()
 
         return field_type, field_params
+    
+    def get_postgis_version(self):
+        """
+        Returns the current postgis version as a tuple
+        """
+        cursor = self.connection.cursor()
+        # an alternate would be "postgis_full_version"
+        v_sql = 'SELECT postgis_version()'
+        postgis_version = (1,5)
+        try:
+            cursor.execute(v_sql)
+            VERSION = cursor.fetchone()[0]
+            # Converts the string 
+            # "2.0 USE_GEOS=1 USE_PROJ=1 USE_STATS=1" 
+            # to a tuple (2, 0)
+            postgis_version = tuple([int(s) for s in VERSION[0:4].split('.')])
+            
+        finally:
+            cursor.close()
+
+        return postgis_version
+
