django: Testing POST-based views with json objects

后端 未结 1 681
深忆病人
深忆病人 2021-01-03 19:57

I have a django application with several views that accept json objects via POST requests. The json objects are medium-complex with a few layers of nesting, so I\'m using th

相关标签:
1条回答
  • 2021-01-03 20:16

    The documentation seems to imply that if you pass a content_type parameter to client.post, it will treat the data value as a document and POST it directly. So try this:

    response = c.post('/ajax/call/', content_type='application/json', data=J_string)
    
    0 讨论(0)
提交回复
热议问题