import csvfrom django.http import HttpResponse
def some_view(request):
    # Create the HttpResponse object with the appropriate CSV header.
    response = HttpResponse(content_type='text/csv')
    response['Content-Disposition'] = 'attachment; filename="somefilename.csv"'

    writer = csv.writer(response)
    writer.writerow(['First row', 'Foo', 'Bar', 'Baz'])
    writer.writerow(['Second row', 'A', 'B', 'C', '"Testing"', "Here's
a quote"])

    return response


On Tue, Oct 16, 2018 at 9:39 AM Shareef 617 <shareef...@gmail.com> wrote:

> Help me to Generate CSV through Django View from database - and download
> the same
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/d3faf615-5b41-4c5d-ad45-d233e1dbd62a%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/d3faf615-5b41-4c5d-ad45-d233e1dbd62a%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHV4E-eATubT%2B6MKbCBAyy%3D14eG_8tjbP824sN7WhS6ubjc7OQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to