hi,

i successfully made a csv export view for a queryset but i have the
problem with some characters...
how can i encode the queryset passed to the csv writer to solve my problem?

#my csvexport.py

    import csv
    from django.http import HttpResponse
    from django.contrib.auth.decorators import login_required

    from myapp.models import Project

    @login_required
    def projects_csv(request):
       
        response = HttpResponse(mimetype='text/csv')
        response['Content-Disposition'] = 'attachment;
    filename=Projects.csv'

        csv_data = Project.objects.all()

        writer = csv.writer(response)
        writer.writerow(['title' ,'area' , 'type', 'axis','beneficiary',
                                  'description', 'budget', 'already paid
    amount ',
                                  'length', 'financing' ,
    'total_amount_to_finance', 'percentage_to_pay' ,
                                  'restamountto_pay', 'security', 'date'])
        for project in csv_data:
                writer.writerow([ project.title , project.area ,
    project.type, project.axis,project.beneficiary,
                                  project.description, project.budget,
    project.already_paid_amount,
                                  project.length, project.financing,
    project.total_amount_to_finance, project.percentage_to_pay_by_tis ,
                                  project.restamount_to_pay,
    project.security, project.pub_date ])
        return response

thank you...



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to