Export data to a CSV file with Django
前言:單純因為會用到,所以就剛好寫到這個功能
想說,以後可能在別的公司or自己的server會用到,就順便整理一份範例。
Example Code:https://gist.github.com/kilfu0701/7332112
# in some views.py, to serve a csv file in Django.
# -*- coding: utf-8 -*-
import csv
from django.http import HttpResponse
def donwload_csv(request):
# change export csv formatting by request parameter. ( url?encode=utf-8 )
encode = request.GET.get('encode', 'big5')
response =...
2013年12月30日 星期一
2013年1月16日 星期三
New
剛好看到有人在gist上放了 安裝python2.7的shell script
其實安裝起來還蠻方便的..(笑)
Shell script code:
https://gist.github.com/1069219
安裝完畢後,執行python就可以看到版本是2.7.2了
不過有人會想問,那要用回舊的版本勒?
其實可以修改 ~/.profile 這檔案,檔案內容大致上如下:
if [ "$BASH" ]; then
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
fi
mesg n
#if [ -d "$HOME/env/bin" ] ; then
# PATH="$HOME/env/bin:$PATH"
#fi
把 PATH="$HOME/env/bin:$PATH"註解掉後,就會套用舊的環境設定。
PS: 恩...原本python2.6裝的django是1.4版的,剛好順便升級到py27 + django-1.5...