'Overrides the default to enable redirecting to the directory view after
deletion of a image.
we need to fetch the object and find out who the parent is
before super, because super will delete the object and make it
impossible to find out the parent folder to redirect to.'

def delete_view(self, request, object_id, extra_context=None):

    try:
        obj = self.get_queryset(request).get(pk=unquote(object_id))
        parent_folder = obj.folder
    except self.model.DoesNotExist:
        parent_folder = None
    if request.POST:
        super(FileAdmin, self).delete_view(request=request, object_id=object_id, extra_context=extra_context)
        if parent_folder:
            url = reverse('admin:filer-directory_listing', kwargs={'folder_id': parent_folder.id})
        else:
            url = reverse('admin:filer-directory_listing-unfiled_images')
        url = '{0}{1}'.format(url, admin_url_params_encoded(request))
        return HttpResponseRedirect(url)
    return super(FileAdmin, self).delete_view(request=request, object_id=object_id, extra_context=extra_context)
