I have the following errors: why append is not done?
'int' object has no attribute 'append'
Request Method: | GET |
---|---|
Request URL: | http://article/export_excel/ |
Django Version: | 1.6.2 |
Exception Type: | AttributeError |
Exception Value: | 'int' object has no attribute 'append' |
Exception Location: | /var/www/html/staff/views.py in export_excel, line 181 |
Python Executable: | /usr/bin/python |
Python Version: | 2.6.6 |
Python Path: | ['/usr/lib/python2.6/site-packages/pip-1.5.2-py2.6.egg', '/usr/lib64/python26.zip', '/usr/lib64/python2.6', '/usr/lib64/python2.6/plat-linux2', '/usr/lib64/python2.6/lib-tk', '/usr/lib64/python2.6/lib-old', '/usr/lib64/python2.6/lib-dynload', '/usr/lib64/python2.6/site-packages', '/usr/lib/python2.6/site-packages', '/usr/lib/python2.6/site-packages/setuptools-0.6c11-py2.6.egg-info', '/var/www/html/ihttest/ihttcs_test/kojin', '/var/www/html/ihttest/ihttcs_test/kojin/static/'] |
Server time: | Wed, 21 May 2014 12:15:09 +0900 |
/usr/lib/python2.6/site-packages/django/core/handlers/base.py
in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)...
/var/www/html/staff/views.py
in export_excel
row[0][0].append(a)...
This is my views.py:
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)
titles = ["No","名前".encode("Shift_JIS"),"日付".encode("Shift_JIS"),"出勤時間".encode("Shift_JIS"), "退勤>時間".encode("Shift_JIS")]
writer.writerow(titles)
obj_all = Myattendance.objects.filter(id = 1).values_list('user', 'contact_date', 'contact_time').order_by("-contact_time")
lea = Myleavework.objects.filter(id = 1).values_list('contact_time').order_by('-contact_time')
row = [[0 for i in range(5)] for i in range(31)]
for a in obj_all.filter().values_list('user_id'):
row[0][0].append(a)
for b in obj_all.filter().values_list('contact_date'):
row[0][1].append(b)
for c in obj_all.filter().values_list('contact_time'):
row[0][2].aapend(c)
writer.writerow(row)
return response