gpt4 book ai didi

python - 我如何更改渲染以在 Django View 中返回 json

转载 作者:太空宇宙 更新时间:2023-11-03 12:54:44 25 4
gpt4 key购买 nike

<分区>

我有功能在看

from django.shortcuts import render
from .models import myModel

def articleTheme(request):
if request.method == 'POST':
article_id = request.POST['id']
article = myModel.objects.get(id=article_id)
theme = article.theme
return render(request, 'theme.html', {'newTheme': theme })

现在可以正常使用了。但是我有多余的html。我想要返回 json 对象。我可以进口和退回什么?

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com