Hello,

I want to export file from database and from two objects;

I'm use MYSQL, 

I have two objects:
1, attendance object:
2. get_work object:

I now can export one object's datas;
So, i how can export datas of two objects;

My the views.py is here:

def export_excel(request):
    response = HttpResponse(mimetype='application/vnd.ms-excel; 
charset="Shift_JIS"')
    response['Content-Disposition'] = 'attachment; filename=file.csv'
    writer = csv.writer(response)
    obj_all=attendance.objects.all()
    s = get_work object:
    for obj in obj_all:
        row=[]
        for field in Myattendance._meta.fields:
            row.append(unicode(getattr(obj,field.name)).encode("cp932"))
        writer.writerow(row)

    return response

and the urls.py is here ;

url(r'^export_excel/$', "staffprofile.views.export_excel"),

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ac6e407a-4b8a-46ca-a286-354d04dac3cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to