On Fri, Mar 8, 2013 at 7:52 PM, galgal <[email protected]> wrote:

> As in the topic - how can I prepare POST data dictionary in TestCase to
> send it via POST?
> I can see how it works in real admin POST in Chrome:
>
> ------WebKitFormBoundaryEXChB8PRJPhaP3OQ
> Content-Disposition: form-data; name="visibly_usergroup" 1
> ------WebKitFormBoundaryEXChB8PRJPhaP3OQ
> Content-Disposition: form-data; name="visibly_usergroup" 2
> ------WebKitFormBoundaryEXChB8PRJPhaP3OQ
> Content-Disposition: form-data; name="visibly_usergroup" 5
>
> How to simulate that?
>

Hi,

You don't need to concern yourself about the POST data encoding -- you just
pass in a list of values instead of a single value to the data argument in
the test client.

self.client.post('/your/url/here'/, data={'visibly_usergroup':
['1','2','5']}

This is all covered in the docs; specifically on the section on POST
operation of the test client:

https://docs.djangoproject.com/en/1.5/topics/testing/overview/#django.test.client.Client.post

Yours,
Russ Magee %-)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to