[GeoNode-users] How to establish a relation between a layer and a document in the GeoNode database

Eloi eloi at openmailbox.org
Wed Mar 8 13:36:26 PST 2017

No bug here, it was my mistake deleting the layer of course the document loses the relationship with the layer because it is not there anymore. 

But maybe the field  object_id in documents_document should be SET NULL instead of NO ACTION, by the constraint and when the layer is deleted. 



On 8 March 2017 20:45:30 CET, Paolo Corti <pcorti at gmail.com> wrote:
>Shouldn't we file a bug here and fix it in the code base?
>On Wed, Mar 8, 2017 at 8:09 AM, Eloi <eloi at openmailbox.org> wrote:
>> Thanks for your quick reply Simone.
>> It was very helpful. Now I can see in a SQL query how Documents and
>> relate:
>> SELECT d.resourcebase_ptr_id AS doc_id,
>>        l.resourcebase_ptr_id AS lay_id,
>>        d.title_en AS doc_title,
>>        l.title_en AS lay_title
>> FROM documents_document AS d
>> LEFT JOIN layers_layer  AS l ON l.resourcebase_ptr_id = d.object_id
>> ORDER BY l.title_en;
>> And I was wrong when I said "every time I run the command "python
>> updatelayers" all established relations (between a layers and a
>> disappear". That is not true, they did disappear because I have
>delete the
>> layers in order to restore them again in the update. So my fault.
>> learning.
>> Thank you very much for the help.
>> Cheers,
>> Eloi
>> On 2017-03-08 11:50, Simone Dalmasso wrote:
>>> Hi,
>>> The layers are actually saved in the layer_layer table but the
>relation is
>>> in document_document and points to the ContentType model. It is a
>>> relation since it can point to any other geonode resource. The two
>>> that you have to compile in the document table are the contenty_type
>(the id
>>> if the layer content type in your case) and object_id(the id of the
>>> layer.)
>>> Hope this helps
>>> 2017-03-08 10:05 GMT+01:00 Eloi <eloi at openmailbox.org>:
>>>> Good morning,
>>>> I would like to establish the relation between a layer and a
>>>> using the GeoNode database and not using the web interface.
>>>> I saw that the layers are listed in table 'base_resourcebase' and
>>>> documents in 'documents_document'. So I wonder in which table the
>>>> between the previous two is recorded. Then I would just run my SQL
>code to
>>>> define does relations.
>>>> Why I want to do this? Because every time I run the command "python
>>>> manage.py updatelayers" all established relations (between a layers
>and a
>>>> documents) disappear.
>>>> Thank you in advance!
>>>> Cheers,
>>>> Eloi
>> _______________________________________________
>> geonode-users mailing list
>> geonode-users at lists.osgeo.org
>> https://lists.osgeo.org/mailman/listinfo/geonode-users
>Paolo Corti
>Geospatial software developer
>web: http://www.paolocorti.net
>twitter: @capooti
>skype: capooti
>geonode-users mailing list
>geonode-users at lists.osgeo.org

Sent from my Android device with K-9 Mail. Please excuse my brevity.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geonode-users/attachments/20170308/edec7b81/attachment.html>

More information about the geonode-users mailing list