def post(self, request, *args, **kwargs): frm = SearchForm(request.POST) if frm.is_valid(): data = frm.cleaned_data self.d_from = data['date_from'] self.d_to = data['date_to'] self.kw = data['kw'] self.domain = data['domain'] self.scheduled = data['scheduled'] return self.get(request, *args, **kwargs)
def post(self, req, *args, **kwargs): frm = SearchForm(req.POST) if frm.is_valid(): data = frm.cleaned_data self.d_from = data['date_from'] self.d_to = data['date_to'] self.kw = data['kw'] self.domain = data['domain'] self.scheduled = data['scheduled'] res_gen, fname = self.get_queryset_csv() # response = HttpResponse(res['stream'].read(), # content_type='application/vnd.openxmlformats-officedocument.spreadsheetml.sheet') # response['Content-Disposition'] = 'attachment; filename="{0}"'.format(res['name']) response = StreamingHttpResponse(res_gen, content_type='text/csv') response['Content-Disposition'] = 'attachment; filename="' + fname + '"' return response