*Previously posted in 
SO: 
http://stackoverflow.com/questions/29703930/testing-request-parameters-in-django-behaves-differently*
-----------------------

I have a Django View that uses a query parameter to so some content 
filtering. Something like this:

/page/?filter=one+and+two/page/?filter=one,or,two

I have noticed that Django converts the + to a space (
request.GET.get('filter') returns one and two), and I´m OK with that. I 
just need to adjust the split() function I use in the View accordingly.

*But...*

When I try to test this View, and I call:

from django.test import Client
client = Client()
client.get('/page/', {'filter': 'one+and+two'})

request.GET.get('filter') returns one+and+two: with plus signs and no 
spaces. Why is this?

I would like to think that Client().get() mimics the browser behaviour, so 
what I would like to understand is why calling client.get('/page/', 
{'filter': 'one+two+three'}) is not like browsing to 
/page/?filter=one+and+two. For testing purposes it should be the same in my 
opinion, and in both cases the view should receive a consistent value for 
filter: be it with + or with spaces. What I don´t get is why there are two 
different behaviours.

-- 
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.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ae167e22-3cb6-4201-a301-204a02a3de2b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to