Repository: django-cms/django-filer

Issue:
KeyError: 'location'
``` python
Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/wsgiref/handlers.py", line 85, in run
    self.result = application(self.environ, self.start_response)
  File "/Users/bashu/Projects/django-sigma-cms-demo/virtualenv/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 63, in __call__
    return self.application(environ, start_response)
  File "/Users/bashu/Projects/django-sigma-cms-demo/virtualenv/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 189, in __call__
    response = self.get_response(request)
  File "/Users/bashu/Projects/django-sigma-cms-demo/virtualenv/lib/python2.7/site-packages/django/core/handlers/base.py", line 218, in get_response
    response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
  File "/Users/bashu/Projects/django-sigma-cms-demo/virtualenv/lib/python2.7/site-packages/django/core/handlers/base.py", line 132, in get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/bashu/Projects/django-sigma-cms-demo/virtualenv/lib/python2.7/site-packages/django/contrib/admin/options.py", line 616, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/Users/bashu/Projects/django-sigma-cms-demo/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py", line 110, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/Users/bashu/Projects/django-sigma-cms-demo/virtualenv/lib/python2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/Users/bashu/Projects/django-sigma-cms-demo/virtualenv/lib/python2.7/site-packages/django/contrib/admin/sites.py", line 233, in inner
    return view(request, *args, **kwargs)
  File "/Users/bashu/Projects/django-sigma-cms-demo/virtualenv/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1519, in change_view
    return self.changeform_view(request, object_id, form_url, extra_context)
  File "/Users/bashu/Projects/django-sigma-cms-demo/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py", line 34, in _wrapper
    return bound_func(*args, **kwargs)
  File "/Users/bashu/Projects/django-sigma-cms-demo/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py", line 110, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/Users/bashu/Projects/django-sigma-cms-demo/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py", line 30, in bound_func
    return func.__get__(self, type(self))(*args2, **kwargs2)
  File "/Users/bashu/Projects/django-sigma-cms-demo/virtualenv/lib/python2.7/site-packages/django/utils/decorators.py", line 145, in inner
    return func(*args, **kwargs)
  File "/Users/bashu/Projects/django-sigma-cms-demo/virtualenv/lib/python2.7/site-packages/django/contrib/admin/options.py", line 1475, in changeform_view
    return self.response_change(request, new_object)
  File "/Users/bashu/Projects/django-sigma-cms-demo/virtualenv/src/django-filer/filer/admin/fileadmin.py", line 70, in response_change
    if r['Location']:
  File "/Users/bashu/Projects/django-sigma-cms-demo/virtualenv/lib/python2.7/site-packages/django/http/response.py", line 208, in __getitem__
    return self._headers[header.lower()][1]
KeyError: 'location'
```



Discussion:

Resolving patch:
diff --git a/filer/admin/fileadmin.py b/filer/admin/fileadmin.py
--- a/filer/admin/fileadmin.py
+++ b/filer/admin/fileadmin.py
@@ -57,7 +57,7 @@ def response_change(self, request, obj):
         instead of the default change_list_view
         """
         r = super(FileAdmin, self).response_change(request, obj)
-        if r['Location']:
+        if 'Location' in r and r['Location']:
             # it was a successful save
             if (r['Location'] in ['../'] or
                 r['Location'] == self._get_post_url(obj)):
@@ -132,4 +132,4 @@ def get_model_perms(self, request):
             'delete': False,
         }
 
-FileAdmin.fieldsets = FileAdmin.build_fieldsets()
\ No newline at end of file
+FileAdmin.fieldsets = FileAdmin.build_fieldsets()


Test patch: