【问题标题】:Overrided Multi Select BooleanField request response django覆盖多选 BooleanField 请求响应 django
【发布时间】:2021-12-19 07:47:56
【问题描述】:

信息在这里:

  1. 这是 views.py 中的 print(request.POST)

  1. 我的意见.py 返回 JsonResponse(request.POST)

{"csrfmiddlewaretoken": "token", "agree_2": "22", "submit_multiple": ""}

enter image description here enter image description here

我想要做的是将post id作为布尔字段中的值,我想要全部

"agree_2":["19","22"]

这是我的 views.py 文件

def index(request):
AVM_Form = AVMForm()
post = PostAVM.objects.all()
context = {
    'form':AVM_Form,
    'post':post,
}
if request.method=='POST':
    if 'submit_single' in request.POST:
        submitPost(request)        
        return HttpResponseRedirect('result/')
    elif 'submit_multiple' in request.POST:
        dump = request.POST
        print(dump)
        return JsonResponse(dump)
return render(request, 'index.html', context)

谁能帮帮我?感谢您的帮助!

【问题讨论】:

    标签: python django frontend


    【解决方案1】:

    我已经解决了。

    我需要这样做才能获得所有列表:

    dump.getlist('agree_2')
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2019-06-21
      • 1970-01-01
      • 1970-01-01
      • 2011-06-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多