'Return a dictionary with keys that are the PostgreSQL object
identification integers for the PostGIS geometry and/or
geography types (if supported).'

def get_postgis_types(self):

    field_types = [('geometry', 'GeometryField'), ('geography', ('GeometryField', {'geography': True}))]
    postgis_types = {}
    oid_sql = 'SELECT    "oid"    FROM    "pg_type"    WHERE    "typname"    =    %s'
    cursor = self.connection.cursor()
    try:
        for field_type in field_types:
            cursor.execute(oid_sql, (field_type[0],))
            for result in cursor.fetchall():
                postgis_types[result[0]] = field_type[1]
    finally:
        cursor.close()
    return postgis_types
