1
こんにちは、私はPythonとDjangoで実際にコーディングにも新しくなっています。Django HTTP.Requestで処理する方法、コンテンツタイプを要求する、クエリパラメータ
私はContent-Type 'application/xml'でPOSTリクエストを受け取ることのできるアプリを作りたいと思っています。
djangoでHTTP.Request.METAを扱う方法がわかりません。 まず、Content_type、次にQuery_string、Content_Lenghtを確認したいと思います。
from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import render
from django.http import (
HttpResponse, HttpResponseNotAllowed, HttpRequest,)
@csrf_exempt
# Check the HTTP Request Method
def app(request):
if request.method != "POST":
return HttpResponseNotAllowed(permitted_methods=('POST',))
else:
# checkcontent(request)
return HttpResponse('OK')
“““
def checkcontent(request):
if not 'application/xml' in request.meta['CONTENT_TYPE']:
raise Exception("Invalid content-type. The expected request content-type is 'application/xml'")
“““
コメントブロックが機能しません!
誰かが私を説明できますか?
Thxを
アナスサイード