忘れないようにメモっとく

機械学習とかプログラミングとか。

Djangoのクロスドメイン問題

http://chase-seibert.github.io/blog/2012/01/27/using-access-control-allow-origin-to-make-cross-domain-post-requests-from-javsacript.html

HttpResponseオブジェクトにヘッダー情報を追加していく。

def index(request):
    """
    ***
    """
    output = []
    output.append({"contents": csvout})
    response = HttpResponse(json.dumps(output), content_type="application/json")
    response["Access-Control-Allow-Origin"] = "*"
    response["Access-Control-Allow-Methods"] = "POST, GET, OPTIONS"
    response["Access-Control-Max-Age"] = "1000"
    response["Access-Control-Allow-Headers"] = "*"
    return response