How to simulate a HTTP Post request from a django view without a template

前端 未结 5 1589
暖寄归人
暖寄归人 2021-02-13 19:11

I am writing views, not so keen to write templates right away.

But I need to test my program by submitting post requests.

How do i simulate HTTP Post from within

5条回答
  •  庸人自扰
    2021-02-13 19:50

    Django has a built in mock Client utility that can mimic requests as if they are coming from a browser. If you don't need to fully mimic a browser and just want to invoke your views directly from your tests, consider using a RequestFactory instead.

提交回复
热议问题