Request.body не выдает желаемый json в django

я начал изучать api вещи в django
. мне нужен JsonResponse в Django, но я не могу его получить

views.py

from django.shortcuts import render
from django.http import JsonResponse
import json

# Create your views here.

def api_home(request, *args, **kwargs):
    body = request.body
    print(body)
    data = {}
    try:
        data = json.loads(body)
    except:
        pass
    # print(data)
    data['headers'] = dict(request.headers)
    data['content_type'] = request.content_type
    return JsonResponse(data)

Вывод в терминал

b''

ожидаемый OUTPUT

b'{"query":"Hello World!"}' 

Файл Python

import requests

endpoint = "http://127.0.0.1:8000/api"

get_response = requests.get(endpoint, json={"query":"Hello World!"})

print(get_response.json())

Выход этого файла

{'headers': {'Content-Length': '', 'Content-Type': 'text/plain', 'Host': 
'127.0.0.1:8000', 'User-Agent': 'python-requests/2.27.1', 'Accept-Encoding': 'gzip, 
deflate', 'Accept': '*/*', 'Connection': 'keep-alive'}, 'content_type': 'text/plain'}

Ожидаемый ВЫХОД

{'query':'Hello World!','headers': {'Content-Length': '', 'Content-Type': 'text/plain', 
'Host':'127.0.0.1:8000', 'User-Agent': 'python-requests/2.27.1', 'Accept-Encoding': 
'gzip,deflate', 'Accept': '*/*', 'Connection': 'keep-alive'}, 'content_type': 
'text/plain'}

Я не понимаю, почему я получаю разные результаты здесь

Введенная ссылка не содержит '/' в конце endpoint = "http://127.0.0.1:8000/api/"

Вернуться на верх