def tablib_export_action(modeladmin, request, queryset, file_type="xls"):
    """
    Allow the user to download the current filtered list of items

    :param file_type:
        One of the formats supported by tablib (e.g. "xls", "csv", "html",
        etc.)
    """

    dataset = SimpleDataset(queryset, headers=None)
    filename = '{0}.{1}'.format(
        smart_str(modeladmin.model._meta.verbose_name_plural), file_type)

    response_kwargs = {
        'content_type': get_content_type(file_type)
    }

    response = HttpResponse(getattr(dataset, file_type), **response_kwargs)
    response['Content-Disposition'] = 'attachment; filename={0}'.format(
        filename)
    return response
Allow the user to download the current filtered list of items

    :param file_type:
        One of the formats supported by tablib (e.g. "xls", "csv", "html",
        etc.)