[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. 

Cheers, 

Eloi 

On 8 March 2017 20:45:30 CET, Paolo Corti <pcorti at gmail.com> wrote:
>Hi
>Shouldn't we file a bug here and fix it in the code base?
>p
>
>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
>Layers
>> 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
>manage.py
>> updatelayers" all established relations (between a layers and a
>documents)
>> 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.
>Still
>> 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
>generic
>>> relation since it can point to any other geonode resource. The two
>fields
>>> 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
>target
>>> 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
>document
>>>> 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
>relation
>>>> 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
>https://lists.osgeo.org/mailman/listinfo/geonode-users

-- 
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