mercredi 13 janvier 2021

Django: Passing 'name' to Client.post()

I want to pass 'name' variable to request.POST.get() from Client in test in Django to be further processed by post function in view.

Something like that(product is ChoiceField in form):

response = c.post('/ordersys/orders/create/', {'product':product, 'amount':3}, name="Add")

I want that if to be True when posting from Client:

if request.POST.get("Add"):
   self.add_to_order(product, amount)

In form, submit like that works:

<input type="submit" name="Add" value="Add item to order">

Aucun commentaire:

Enregistrer un commentaire