예제 #1
0
 def render_to_response(self, context, **response_kwargs):
     qs = context['filter'].qs.values()
     file_buffer = export_targets(qs)
     file_buffer.seek(0)  # goto the beginning of the buffer
     response = StreamingHttpResponse(file_buffer, content_type="text/csv")
     filename = "targets-{}.csv".format(slugify(datetime.utcnow()))
     response['Content-Disposition'] = 'attachment; filename="{}"'.format(
         filename)
     return response
예제 #2
0
    def render_to_response(self, context, **response_kwargs):
        """
        Returns a response containing the exported CSV of selected targets.

        :param context: Context object for this view
        :type context: dict

        :returns: response class with CSV
        :rtype: StreamingHttpResponse
        """
        qs = context['filter'].qs.values()
        file_buffer = export_targets(qs)
        file_buffer.seek(0)  # goto the beginning of the buffer
        response = StreamingHttpResponse(file_buffer, content_type="text/csv")
        filename = "targets-{}.csv".format(slugify(datetime.utcnow()))
        response['Content-Disposition'] = 'attachment; filename="{}"'.format(filename)
        return response