<html><head></head><body>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. <br>
<br>
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. <br>
<br>
Cheers, <br>
<br>
Eloi <br><br><div class="gmail_quote">On 8 March 2017 20:45:30 CET, Paolo Corti <pcorti@gmail.com> wrote:<blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">
<pre class="k9mail">Hi<br />Shouldn't we file a bug here and fix it in the code base?<br />p<br /><br />On Wed, Mar 8, 2017 at 8:09 AM, Eloi <eloi@openmailbox.org> wrote:<br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #729fcf; padding-left: 1ex;"> Thanks for your quick reply Simone.<br /><br /> It was very helpful. Now I can see in a SQL query how Documents and Layers<br /> relate:<br /><br /> SELECT d.resourcebase_ptr_id AS doc_id,<br /> l.resourcebase_ptr_id AS lay_id,<br /> d.title_en AS doc_title,<br /> l.title_en AS lay_title<br /> FROM documents_document AS d<br /> LEFT JOIN layers_layer AS l ON l.resourcebase_ptr_id = d.object_id<br /> ORDER BY l.title_en;<br /><br /> And I was wrong when I said "every time I run the command "python <a href="http://manage.py">manage.py</a><br /> updatelayers" all established relations (between a layers and a documents)<br /> disappear". That is not true, they did disappear because I have delete the<br /> layers in order to restore them again in the update. So my fault. Still<br /> learning.<br /><br /> Thank you very much for the help.<br /><br /> Cheers,<br /><br /> Eloi<br /><br /><br /> On 2017-03-08 11:50, Simone Dalmasso wrote:<br /><br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #ad7fa8; padding-left: 1ex;"> Hi,<br /><br /> The layers are actually saved in the layer_layer table but the relation is<br /> in document_document and points to the ContentType model. It is a generic<br /> relation since it can point to any other geonode resource. The two fields<br /> that you have to compile in the document table are the contenty_type (the id<br /> if the layer content type in your case) and object_id(the id of the target<br /> layer.)<br /><br /> Hope this helps<br /><br /> 2017-03-08 10:05 GMT+01:00 Eloi <eloi@openmailbox.org>:<br /><br /><blockquote class="gmail_quote" style="margin: 0pt 0pt 1ex 0.8ex; border-left: 1px solid #8ae234; padding-left: 1ex;"> Good morning,<br /><br /> I would like to establish the relation between a layer and a document<br /> using the GeoNode database and not using the web interface.<br /> I saw that the layers are listed in table 'base_resourcebase' and<br /> documents in 'documents_document'. So I wonder in which table the relation<br /> between the previous two is recorded. Then I would just run my SQL code to<br /> define does relations.<br /><br /> Why I want to do this? Because every time I run the command "python<br /> <a href="http://manage.py">manage.py</a> updatelayers" all established relations (between a layers and a<br /> documents) disappear.<br /><br /> Thank you in advance!<br /><br /> Cheers,<br /><br /> Eloi<br /></blockquote></blockquote><br /><br /><hr /><br /> geonode-users mailing list<br /> geonode-users@lists.osgeo.org<br /> <a href="https://lists.osgeo.org/mailman/listinfo/geonode-users">https://lists.osgeo.org/mailman/listinfo/geonode-users</a><br /></blockquote><br /><br /></pre></blockquote></div><br>
-- <br>
Sent from my Android device with K-9 Mail. Please excuse my brevity.</body></html>