[GeoNode-users] Extend autocomplete-light with new fields

Simone Dalmasso simone.dalmasso at gmail.com
Wed Feb 22 04:46:42 PST 2017


Hi, definitely the second way is the one to go with. You can see what
there's already in geonode and make your own
https://github.com/GeoNode/geonode/blob/master/geonode/base/autocomplete_light_registry.py
and
call it from the template using the correct name, see
https://github.com/GeoNode/geonode/blob/master/geonode/templates/base.html#L296
.

 hope this helps

2017-02-22 13:26 GMT+01:00 Toni Schönbuchner <toni.schoenbuchner at csgis.de>:

> Hi together,
>
> this might be an easy one. In geonode 2.4 I have extended autocomplete
> registry to search in more fields
> on layers left side title-search-input.
>
> https://github.com/GeoNode/geonode/blob/2.4.x/geonode/
> base/autocomplete_light_registry.py
>
> autocomplete_light.register(ResourceBase,
> search_fields=*[‘title‘,’abstract’,’purpose'],*
> autocomplete_js_attributes={'placeholder': 'Resource name..', },)
>
> then changed the base model to return abstract and purpose content as well:
>
> https://github.com/GeoNode/geonode/blob/2.4.x/geonode/base/models.py#L342
>     def __unicode__(self):
>         return self.title + ’,’ + self.abstract + ’,’ + self.purpose
>
>
> The result is a user can search f.e. for ‚dog‘ and autocomplete shows
> choices like:
> *Dog Title, Dogs Heaven, the purpose is sleep*
> *Dogs world, Dogs Hell, the purpose is eat*
>
> All that is missing is that I do not want to show a field when the search
> term is not
> found in it. F.e. if purpose does not has ‚dog‘ autoselect should not show
> it.
> *Dog Title, Dogs Heaven*
> *…*
>
> From the documentation of DAL I assumed that the way to go is to
> create/register a subclass like:
>
> class CustomResource(autocomplete_light.AutocompleteModelBase):
>     search_fields = ['title', ‚abstract‘,’purpose']
>     model = ResourceBase
>
> autocomplete_light.register(CustomResource)
>
> and override the httpResponse method. Unfortunately this basic step
> already ends in a 404.
> Maybe one could bring me on the right track how to achieve filtering the
> return.
>
> Thanks,
>
> Toni
>
> _______________________________________________
> geonode-users mailing list
> geonode-users at lists.osgeo.org
> https://lists.osgeo.org/mailman/listinfo/geonode-users
>
>


-- 
Simone
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/geonode-users/attachments/20170222/d3a01c09/attachment.html>


More information about the geonode-users mailing list