Display form errors with django and ajax

后端 未结 3 1024
盖世英雄少女心
盖世英雄少女心 2021-02-06 06:21

I have a contact form through which users would be able to contact me. I am using django with ajax, and it works fine if there\'s no error. I would like to show

3条回答
  •  忘了有多久
    2021-02-06 07:11

    You need to define status_code argument for JsonResponse.

    return JsonResponse(data, status_code=400)
    

    This way it will end up in the error callback in $.ajax.

提交回复
热议问题