GeoNode / geonode

GeoNode is an open source platform that facilitates the creation, sharing, and collaborative use of geospatial data.
https://geonode.org/
Other
1.45k stars 1.13k forks source link

Error adding keywords to a Layer when they already exist (related to Hierarchical Keywords) #2659

Closed gdreich closed 8 years ago

gdreich commented 8 years ago

Example: "human health" already exists in Hierarchical Keywords IntegrityError at /admin/layers/layer/48/ duplicate key value violates unique constraint "base_hierarchicalkeyword_name_key" DETAIL: Key (name)=(human health) already exists.

The keywords are trying to be added again even if they exist.

gdreich commented 8 years ago

This affects multiple word keywords only e.g. "human health", since the slug won't be in str_tags if its more than one word, not sure if this is intended or not. existing = self.through.tag_model().objects.filter(slug__in=str_tags) is it feasible to change the filter to name__in=str_tags? https://github.com/GeoNode/geonode/blob/master/geonode/base/models.py#L286.

fdetsch commented 8 years ago

I encounter the same problem. Is there any solution yet?

gdreich commented 8 years ago

https://github.com/gdreich/geonode/commit/eeced04489d617f797c11fb18666240832f3ea01

did the trick for me