วันพุธที่ 1 มีนาคม พ.ศ. 2560

Account#5: Import CSV

urls.py

เพิ่ม url ของการ import csv

views.py

ฟังก์ชั่นอัพโหลดไฟล์
ตรง file = request.FILES['file'] ชื่อ file จะต้องเหมือนใน forms.py
คำสั่ง codecs.iterdecode เพื่อ decode จากไฟล์ที่เป็น bytes ให้เป็น text ที่สามารถอ่านได้ กรณีไม่ใส่ iterdecode จะขึ้น error
iterator should return strings, not bytes (did you open the file in text mode?)
เรียกใช้ฟังก์ชั่น overwrite_transaction เพื่อแก้ไข ข้อมูล transaction ใน account และเขียนทับลงไปใหม่


newfile forms.py


upload.html

ใน tag form จะต้องมีส่วน enctype="multipart/form-data" และ method="post" เพื่อให้ส่งข้อมูลไปได้

สร้างปุ่ม import csv
หน้าตาประมาณนี้

commit เพิ่มเติม : เพื่ม userstory, bookmark

>>  add userstory ทำการเพิ่ม userstory ใน functional tests >>  add bookmark for user เพิ่มระบบ Bookmark โดยการสร้าง model ขึ...