lundi 13 juillet 2020

How to Post a List in Django Tests

How can I post a list in a django test? I retrieve the data through this command:

listVar = request.POST.getlist('list[]')

I know this receives a list properly because I interface with Jquery and it returns the proper list, but how can I do this is python? I have been trying code like this however printing 'listVar' always yields an empty list:

form = {"list": ["element 1", "element 2"]}
response = self.client.post('/viewurl/', form, follow=True)

Aucun commentaire:

Enregistrer un commentaire