<div dir="ltr">Hi, definitely the second way is the one to go with. You can see what there's already in geonode and make your own <a href="https://github.com/GeoNode/geonode/blob/master/geonode/base/autocomplete_light_registry.py">https://github.com/GeoNode/geonode/blob/master/geonode/base/autocomplete_light_registry.py</a> and call it from the template using the correct name, see <a href="https://github.com/GeoNode/geonode/blob/master/geonode/templates/base.html#L296">https://github.com/GeoNode/geonode/blob/master/geonode/templates/base.html#L296</a>.<div><br></div><div> hope this helps</div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-02-22 13:26 GMT+01:00 Toni Schönbuchner <span dir="ltr"><<a href="mailto:toni.schoenbuchner@csgis.de" target="_blank">toni.schoenbuchner@csgis.de</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">Hi together,<div><br></div><div>this might be an easy one. In geonode 2.4 I have extended autocomplete registry to search in more fields</div><div>on layers left side title-search-input.</div><div><br></div><div><a href="https://github.com/GeoNode/geonode/blob/2.4.x/geonode/base/autocomplete_light_registry.py" target="_blank">https://github.com/GeoNode/<wbr>geonode/blob/2.4.x/geonode/<wbr>base/autocomplete_light_<wbr>registry.py</a></div><div><br></div><div><div>autocomplete_light.register(<wbr>ResourceBase,</div><div><span class="m_7830546296618264870Apple-tab-span" style="white-space:pre-wrap">    </span>search_fields=<b>[‘title‘,’<wbr>abstract’,’purpose'],</b></div><div><span class="m_7830546296618264870Apple-tab-span" style="white-space:pre-wrap">  </span>autocomplete_js_attributes={'<wbr>placeholder': 'Resource name..', },)</div></div><div><br></div><div>then changed the base model to return abstract and purpose content as well:</div><div><br></div><div><a href="https://github.com/GeoNode/geonode/blob/2.4.x/geonode/base/models.py#L342" target="_blank">https://github.com/GeoNode/<wbr>geonode/blob/2.4.x/geonode/<wbr>base/models.py#L342</a></div><div><div>    def __unicode__(self):</div><div>        return self.title + ’,’ + self.abstract + ’,’ + self.purpose</div></div><div><br></div><div><br></div><div>The result is a user can search f.e. for ‚dog‘ and autocomplete shows choices like:</div><div><b>Dog Title, Dogs Heaven, the purpose is sleep</b></div><div><b>Dogs world, Dogs Hell, the purpose is eat</b></div><div><b><br></b></div><div>All that is missing is that I do not want to show a field when the search term is not</div><div>found in it. F.e. if purpose does not has ‚dog‘ autoselect should not show it.</div><div><div><b>Dog Title, Dogs Heaven</b></div></div><div><b>…</b></div><div><b><br></b></div><div>From the documentation of DAL I assumed that the way to go is to create/register a subclass like:</div><div><br></div><div><div>class CustomResource(autocomplete_<wbr>light.AutocompleteModelBase):</div><div>    search_fields = ['title', ‚abstract‘,’purpose']</div><div>    model = ResourceBase</div><div><br></div><div>autocomplete_light.register(<wbr>CustomResource)</div></div><div><br></div><div>and override the httpResponse method. Unfortunately this basic step already ends in a 404.</div><div>Maybe one could bring me on the right track how to achieve filtering the return.</div><div><br></div><div>Thanks,</div><div><br></div><div>Toni</div></div><br>______________________________<wbr>_________________<br>
geonode-users mailing list<br>
<a href="mailto:geonode-users@lists.osgeo.org">geonode-users@lists.osgeo.org</a><br>
<a href="https://lists.osgeo.org/mailman/listinfo/geonode-users" rel="noreferrer" target="_blank">https://lists.osgeo.org/<wbr>mailman/listinfo/geonode-users</a><br>
<br></blockquote></div><br><br clear="all"><div><br></div>-- <br><div class="gmail_signature" data-smartmail="gmail_signature">Simone </div>
</div>