[GeoNode-users] Postgis extension on geonode DB

Paolo Corti pcorti at gmail.com
Thu May 14 01:25:09 PDT 2015


Hi Renata
I thought you have an existing project in the public schema, and want
to add models from a different legacy database/schema. This is
something I have been doing in the past and I it was working well.
In any case, using django 1.6.10 (same as GeoNode 2.4) I have just
tested this creating a new
project, and in my case it sync the tables in the schema specified in
the 'options'.
I am not sure what could be the problem there, maybe something related
to your configuration?
best
p

On Wed, May 13, 2015 at 6:08 PM, Renata Binotto <rbinotto at arpa.veneto.it> wrote:
> Hi Paolo,
> bad news... we put the string
>
> 'OPTIONS': {
>             'options': '-c search_path=myschema,public'
>         },
>
> in our DATABASES settings in /etc/geonode/local_settings.py but nothing
> changed: when we use the command
>
> python manage.py syncdb --database="my_external_db"
>
> it creates the tables in the public schema again not in "myschema".
> We put search_path in the postgres DB my_external_db (with psql) too, using:
> SET search_path TO myschema, public.
>
> Maybe we miss something...
> Thank you.
> Ciao!
> Renata.
>
>
>
>
> Il 12/05/2015 14:40, Paolo Corti ha scritto:
>>
>> 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:
>> https://docs.djangoproject.com/en/1.8/topics/db/multi-db/
>> * 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:
>>
>> DATABASES = {
>>      '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
>> cheers
>> p
>>
>>> 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