[GeoNode-users] Postgis extension on geonode DB

Paolo Corti pcorti at gmail.com
Tue May 12 05:40:55 PDT 2015

Hi Renata

I think you can create models for tables in a different database/schema.
What you need to do is:

* add a database in DATABASES as suggested by Simone and here:
* if the tables for which you want to create models are in a schema
different from public, you may add this using the OPTIONS setting in
the DATABASES setting:

    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    'my_external_db' : {
        'ENGINE': 'django.contrib.gis.db.backends.postgis',
        'OPTIONS': {
            'options': '-c search_path=yourschema,public'
        'NAME': 'mydb',
        'USER' : 'myuser',
        'PASSWORD' :'secret',
        'HOST' : 'myhost',
        'PORT' : '5432',

By the way, you can use inspectdb to reverse the postgis layers to
django models using the --database option:

$ python manage.py inspectdb --database my_external_db

hope it helps

> 2015-05-12 12:21 GMT+02:00 Renata Binotto <rbinotto at arpa.veneto.it>:
>> Hi all,
>> we have a DB and a postgresql schema (call it ourSchema) with some layers
>> and some tables and we want to edit the tables using Django Admin facilities
>> (with server_ipaddress/admin). We wrote in local_settings in /etc/geonode
>> the connection strings for this DB (ex: ourDB, in the same server with
>> geonode) but after some tests we understood that:
>> -- creating a new app (with python manage.py startapp ...), a models.py
>> with our tables and using python manage.py syncdb --database=ourDB,
>> Geonode re-create all django tables + our tables in the public schema of
>> ourDB ('cause there's no info in local_settings about what schema is
>> connected ourDB);
>> -- but these new tables in ourDB/public are not seen by
>> server_ipaddress/admin, but they are seen only if we create them in the
>> schema geonode(=default)/public;
>> -- so we thought we could put ourSchema inside geonodeDB or all its
>> tables/layers in the geonode/public schema (even if we don't like this
>> solution too much...), but ourSchema contains layers and geonodeDB has no
>> postgis extensions so we couldn't.
>> At the end, some desperate questions:
>> -- is it possible to connect django server_ipaddress/admin to tables in a
>> different DB (putting some connection string in the app directly, for
>> example);
>> -- is it possible to install postgis extension on geonodeDB?
>> Thanks!
>> Renata.
>> _______________________________________________
>> geonode-users mailing list
>> geonode-users at lists.osgeo.org
>> http://lists.osgeo.org/cgi-bin/mailman/listinfo/geonode-users
> --
> Simone
> _______________________________________________
> geonode-users mailing list
> geonode-users at lists.osgeo.org
> http://lists.osgeo.org/cgi-bin/mailman/listinfo/geonode-users

Paolo Corti
Geospatial software developer
web: http://www.paolocorti.net
twitter: @capooti
skype: capooti

More information about the geonode-users mailing list