顯示具有 Django 標籤的文章。 顯示所有文章
顯示具有 Django 標籤的文章。 顯示所有文章

2013年4月2日 星期二

[Django]引用ajax,出現csrf錯誤



2013年3月11日 星期一

[Django] refresh div with JQuery

Example:

Template 1 

<script>

function refresh_infos(element){
    var id = "test"
    $.ajax({
        type: "POST",
        url: '/part_update/',
        data: {'id':id},
        success: function(data) {
            $('#testDIV').html(data);
        }
    });
}
</script>
<div id="testDIV"></div>



View 

def part_update(request):

    id = request.POST.get('id', "")
   
    #/* get infomation */
    infos = DB.objects.filter(id = id)
   

    return render_to_response('supply/template.html', { 'infos': infos })

Template 2 
    {% for info in infos %}
        <p>{{ info.id }}</p>
    {% endif %}


Urls 
    adding:
    (r'^/part_update/$','part_update'),

2013年1月30日 星期三

[Django] 如何取得django form資料


先簡單記錄一下,如何在python後台取得前端傳送的django form資料:


if request.method == "POST":
    form = xxForm(request.POST , prefix='fd')
    if form.is_valid(): # 通過驗證才可取得資料
        print form.cleaned_data['col']
else:
   
    print "It's not from POST !!"

2012年9月2日 星期日

[Django-Firebird] Django連結Firebird整理

首先:

    檔案部分位於:
        Django 1.3 (or higher)  >  django-firebird
        Django 1.4                    >  django-firebird driver on github

    安裝前有一些必須事先安裝的套件:


在安裝時,直接將firebird檔案夾放置於兩個檔案夾下

  •      C:\Python27\Lib\site-packages\django‌​\contrib\gis\db\backends 
  •      C:\Python27\Lib\site-packages


這樣應該就可以順利使用嚕!
更詳細的敘述見參考資料。


參考資料:
http://stackoverflow.com/questions/11930701/django-firebird-can-not-work
http://code.google.com/p/django-firebird/