- 重要な情報
- はじめに
- 用語集
- ガイド
- エージェント
- インテグレーション
- OpenTelemetry
- 開発者
- API
- CoScreen
- アプリ内
- Service Management
- インフラストラクチャー
- アプリケーションパフォーマンス
- 継続的インテグレーション
- ログ管理
- セキュリティ
- UX モニタリング
- 管理
ID: python-django/jsonresponse-no-content-type
言語: Python
重大度: Notice
カテゴリー: ベストプラクティス
JsonResponse
は既にレスポンスのコンテントタイプを設定しています。送信されるコンテントタイプを再定義しないでください。
import json
from django.http import HttpResponse
response_data = {}
response_data['result'] = 'error'
response_data['message'] = 'Some error message'
return JsonResponse(response_data, content_type="application/json") # JsonResponse では content-type は必要ありません
import json
from django.http import HttpResponse
response_data = {}
response_data['result'] = 'error'
response_data['message'] = 'Some error message'
return JsonResponse(response_data) # JsonResponse では content-type は必要ありません