我想将'name'变量传递给请求。在Django的测试中来自Client的POST.get((,将由视图中的POST函数进一步处理。
类似的东西(产品在形式上是ChoiceField(:
response = c.post('/ordersys/orders/create/', {'product':product, 'amount':3}, name="Add")
我希望这是真的,当从客户张贴:
if request.POST.get("Add"):
self.add_to_order(product, amount)
在形式上,像这样提交工作:
<input type="submit" name="Add" value="Add item to order">
感谢Abdul Aziz Barkat在我的帖子下的评论,我能够让它发挥作用。我只需要加上"添加":对我来说是这样。