For example, for GHEC both GHEC map and a FE layer have id = 2. The code changes the title to both.
We tried using Map instead of ResourceBase but the problem is stille there. It looks like that the root cause is stille an issue with IDs and fixtures:
from geonode.maps.models import Map
class Command(BaseCommand):
def handle(self, *args, **options):
titles = ((1, "Instrumental Seismic Catalogue"), (2, "Global Historic Catalogue"), (3, "Global Active Faults"))
for id, name in titles:
table_row = Map.objects.get(id=id) table_row.title = name table_row.save()
If we try to change the layer or map name in the Django admin console with get an ugly error related to keys:
Traceback:
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
115. response = callback(request, *callback_args, **callback_kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in wrapper
372. return self.admin_site.admin_view(view)(*args, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
91. response = view_func(request, *args, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
89. response = view_func(request, *args, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/contrib/admin/sites.py" in inner
202. return view(request, *args, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapper
25. return bound_func(*args, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/utils/decorators.py" in _wrapped_view
91. response = view_func(request, *args, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/utils/decorators.py" in bound_func
21. return func(self, *args2, **kwargs2)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/db/transaction.py" in inner
223. return func(*args, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/contrib/admin/options.py" in change_view
1100. queryset=inline.queryset(request))
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/forms/models.py" in __init__
720. queryset=qs, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/forms/models.py" in __init__
441. super(BaseModelFormSet, self).__init__(**defaults)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/forms/formsets.py" in __init__
56. self._construct_forms()
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/forms/formsets.py" in _construct_forms
124. self.forms.append(self._construct_form(i))
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/forms/models.py" in _construct_form
729. form = super(BaseInlineFormSet, self)._construct_form(i, **kwargs)
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/forms/models.py" in _construct_form
460. pk = self.data[pk_key]
File "/home/openquake/oq-platform/platform-env/local/lib/python2.7/site-packages/django/utils/datastructures.py" in __getitem__
295. raise MultiValueDictKeyError("Key %r not found in %r" % (key, self))
Exception Type: MultiValueDictKeyError at /admin/maps/map/2/
The problem is caused when we try to rename the Maps using https:/ /github. com/gem/ oq-platform/ blob/master/ openquakeplatfo rm/openquakepla tform/maps_ viewer/ management/ commands/ map_title. py#L28
For example, for GHEC both GHEC map and a FE layer have id = 2. The code changes the title to both.
We tried using Map instead of ResourceBase but the problem is stille there. It looks like that the root cause is stille an issue with IDs and fixtures:
from geonode.maps.models import Map
class Command( BaseCommand) :
def handle(self, *args, **options): get(id= id)
table_ row.title = name
table_ row.save( )
titles = ((1, "Instrumental Seismic Catalogue"), (2, "Global Historic Catalogue"), (3, "Global Active Faults"))
for id, name in titles:
table_row = Map.objects.
If we try to change the layer or map name in the Django admin console with get an ugly error related to keys:
Traceback: openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ core/handlers/ base.py" in get_response openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ contrib/ admin/options. py" in wrapper site.admin_ view(view) (*args, **kwargs) openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ utils/decorator s.py" in _wrapped_view openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ views/decorator s/cache. py" in _wrapped_view_func openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ contrib/ admin/sites. py" in inner openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ utils/decorator s.py" in _wrapper openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ utils/decorator s.py" in _wrapped_view openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ utils/decorator s.py" in bound_func openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ db/transaction. py" in inner openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ contrib/ admin/options. py" in change_view inline. queryset( request) ) openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ forms/models. py" in __init__ openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ forms/models. py" in __init__ FormSet, self)._ _init__ (**defaults) openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ forms/formsets. py" in __init__ _forms( ) openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ forms/formsets. py" in _construct_forms append( self._construct _form(i) ) openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ forms/models. py" in _construct_form eFormSet, self)._ construct_ form(i, **kwargs) openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ forms/models. py" in _construct_form openquake/ oq-platform/ platform- env/local/ lib/python2. 7/site- packages/ django/ utils/datastruc tures.py" in __getitem__ eyError( "Key %r not found in %r" % (key, self))
File "/home/
115. response = callback(request, *callback_args, **callback_kwargs)
File "/home/
372. return self.admin_
File "/home/
91. response = view_func(request, *args, **kwargs)
File "/home/
89. response = view_func(request, *args, **kwargs)
File "/home/
202. return view(request, *args, **kwargs)
File "/home/
25. return bound_func(*args, **kwargs)
File "/home/
91. response = view_func(request, *args, **kwargs)
File "/home/
21. return func(self, *args2, **kwargs2)
File "/home/
223. return func(*args, **kwargs)
File "/home/
1100. queryset=
File "/home/
720. queryset=qs, **kwargs)
File "/home/
441. super(BaseModel
File "/home/
56. self._construct
File "/home/
124. self.forms.
File "/home/
729. form = super(BaseInlin
File "/home/
460. pk = self.data[pk_key]
File "/home/
295. raise MultiValueDictK
Exception Type: MultiValueDictK eyError at /admin/maps/map/2/