# StreamingHttpResponse

**URL:** <https://forum.djangoproject.com/t/streaminghttpresponse/9756>\
**Category:** Using Django\
**Created:** [September 19, 2021, 6:55pm UTC](https://forum.djangoproject.com/t/streaminghttpresponse/9756 "2021-09-19T18:55:28Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![AhmedSalam22](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ahmedsalam22/32/5620_2.png) [@AhmedSalam22](https://forum.djangoproject.com/u/AhmedSalam22)\
**Post date:** [September 19, 2021, 6:55pm UTC](https://forum.djangoproject.com/t/streaminghttpresponse/9756/1 "2021-09-19T18:55:28Z")

</div>

```auto
class ExportTrsanctionView(LoginRequiredMixin, View):
    def get(self, request, *args, **kwargs):
        f = TransactionFilter(request.session.get('export_journal'))
        queryset = f.qs.prefetch_related(
            'journal_set' , 'journal_set__account'
        ).filter(journal __account__ owner=request.user).distinct()

        pseudo_buffer = Echo()
        writer = csv.writer(pseudo_buffer)
        writer.writerow(['Date', 'Account', 'balance', 'transaction type' , 'comment'])

        response = StreamingHttpResponse(
            streaming_content=(writer.writerow(
                    [transaction.date , journal.account , journal.balance , journal.transaction_type , transaction.comment]
                ) for transaction in queryset for journal in transaction.journal_set.all() 
            ),
        content_type='text/csv')
        response['Content-Disposition'] = 'attachment; filename="journal{}.csv"'.format(timezone.now().isoformat())
        return response

```

when i try to download data the header not included and i don’t know why  
the header should contain this line

```auto
        writer.writerow(['Date', 'Account', 'balance', 'transaction type' , 'comment'])

```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [September 20, 2021, 2:25am UTC](https://forum.djangoproject.com/t/streaminghttpresponse/9756/2 "2021-09-20T02:25:46Z")

</div>

I don’t know what this Echo class is you’re calling `pseudo_buffer`, or what its behavior is, but you are writing to it outside the context of your StreamingHttpResponse object. So unless it’s a _real_ buffer and not truly a pseudo buffer, you’re not writing the data out to the stream.

---

<div class="post-metadata">

**Author:** ![AhmedSalam22](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ahmedsalam22/32/5620_2.png) [@AhmedSalam22](https://forum.djangoproject.com/u/AhmedSalam22)\
**Post date:** [September 20, 2021, 4:31am UTC](https://forum.djangoproject.com/t/streaminghttpresponse/9756/3 "2021-09-20T04:31:48Z")

</div>

![Screenshot_20210920_063112_com.android.chrome](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/0/00a28d39977703a42769a52c70d80bedad5c8dad.jpeg)
