yourcelf / olwidget

Javascript library to replace textareas that contain WKT data with editable OpenLayers maps, and a django app using it for django forms and admin.
Other
91 stars 44 forks source link

KeyError in admin change list view (Django 1.4) #112

Closed onurmatik closed 11 years ago

onurmatik commented 12 years ago

I am using the latest version of olwidget from the master branch with Django Version 1.4. When I try to delete items selecting from the list view using the "delete selected" admin action, I get the following error:

Traceback:
File "/Library/Python/2.6/site-packages/django/core/handlers/base.py" in get_response
  111.                         response = callback(request, *callback_args, **callback_kwargs)
File "/Library/Python/2.6/site-packages/django/contrib/admin/options.py" in wrapper
  366.                 return self.admin_site.admin_view(view)(*args, **kwargs)
File "/Library/Python/2.6/site-packages/django/utils/decorators.py" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/Library/Python/2.6/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  89.         response = view_func(request, *args, **kwargs)
File "/Library/Python/2.6/site-packages/django/contrib/admin/sites.py" in inner
  196.             return view(request, *args, **kwargs)
File "/Library/Python/2.6/site-packages/django/utils/decorators.py" in _wrapper
  25.             return bound_func(*args, **kwargs)
File "/Library/Python/2.6/site-packages/django/utils/decorators.py" in _wrapped_view
  91.                     response = view_func(request, *args, **kwargs)
File "/Library/Python/2.6/site-packages/django/utils/decorators.py" in bound_func
  21.                 return func(self, *args2, **kwargs2)
File "/Users/omat/workspace/gezgin/env/lib/python2.6/site-packages/olwidget/admin.py" in changelist_view
  130.             map_ = self.get_changelist_map(template_response.context_data['cl'], request)

Exception Type: KeyError at /admin/posts/post/
Exception Value: cl
scdoshi commented 11 years ago

+1 Exact same thing

scdoshi commented 11 years ago

It seems this is the dict that is passed (context_data), which does not have 'cl': (using ------- to substitute for actual data)

{'action_checkbox_name': '_selected_action', 'app_label': '---------', 'deletable_objects': [[------------------]], 'objects_name': u'---------', 'opts': <Options for ----------->, 'perms_lacking': set(), 'protected': [], 'queryset': [----------------------], 'title': u'Are you sure?'}

onurmatik commented 11 years ago

And, for the same model admin, it only happens when certain objects are involved but I couldn't identify why.

scdoshi commented 11 years ago

@omat Added pull request, you can use my fork temporarily if you want. It's a simple fix if you want to just patch your copy too.

onurmatik commented 11 years ago

thanks @scdoshi and sorry for the late response. i confirm that your fix solved the problem.

yourcelf commented 11 years ago

Thanks much, merged.