You might want to try json encoding your data if you want to preserve
integers, lists, etc.

On Thu, Jul 19, 2018 at 10:54 PM Collin Anderson <cmawebs...@gmail.com>
wrote:

> Using your example, the client is sending this string:
>
> ?wordPos=2&wordPos=3
>
> It's not an array like ?wordPos=2,3
>
> On Thu, Jul 19, 2018 at 10:27 PM Zhao Lee <redstone-c...@163.com> wrote:
>
>> I have to confess I don’t know much about web development .
>>
>> I used to expect QueryDict.get(_key_, _default=None_) to return data
>> type that client side offered, for example , if client side send
>> {'wordPos':(2,3)} , I expect get('wordPos') to return it, whereas the
>> current behavior is far from explanation , even using getlist('wordPos'),
>> it just returns ['2','3'], then I have to do additional work to convert
>> it back to its first shape, just found this inconvenient, so I made this
>> post.
>> BTW, why integers were converted to strings after the transmission?
>>
>>
>>
>> 在2018年07月19 20时44分, "Florian Apolloner"<f.apollo...@gmail.com>写道:
>>
>>
>> On Thursday, July 19, 2018 at 8:52:56 AM UTC+2, Carlton Gibson wrote:
>>>
>>> The usual case is to need a single value from the query string, so `[]`
>>> and `get()` both return scalars.
>>> `getList()` exists specifically for the case where you do want multiple
>>> values.
>>>
>>
>> I'd like to expand on this, because the current behaviour has even more
>> important aspects. The query string is supplied by the user and as such is
>> completely untrusted data. If `.get` were to change to return lists if
>> there are lists, this would mean that the user could control the data
>> structures in the view. This is not something we'd ever want.
>>
>> Aside from that it is technically impossible to change the behaviour of
>> get to return lists: What would ?some_param=1 result in? Would it all of a
>> sudden be a list with one item? Since there is no difference between a
>> scalar value and a one item list in terms of query strings, this has to
>> stay the decision of the developer. They are the only ones knowing how the
>> data should look like and can handle it accordingly.
>>
>> Cheers,
>> Florian
>>
>> --
>> You received this message because you are subscribed to a topic in the
>> Google Groups "Django developers  (Contributions to Django itself)" group.
>> To unsubscribe from this topic, visit
>> https://groups.google.com/d/topic/django-developers/snBepnO5AjY/unsubscribe
>> .
>> To unsubscribe from this group and all its topics, send an email to
>> django-developers+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-developers@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-developers.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-developers/4e15b2a8-895e-4c43-9b61-5dce2759d23c%40googlegroups.com
>> <https://groups.google.com/d/msgid/django-developers/4e15b2a8-895e-4c43-9b61-5dce2759d23c%40googlegroups.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>>
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django developers (Contributions to Django itself)" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-developers+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-developers@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-developers.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-developers/47f81b86.5f.164b581f067.Coremail.redstone-cold%40163.com
>> <https://groups.google.com/d/msgid/django-developers/47f81b86.5f.164b581f067.Coremail.redstone-cold%40163.com?utm_medium=email&utm_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/CAFO84S5yuyc7qEQ6F5G3kO%2Bu4OzNzqGhtVDQWu2mkqBfj7P5mQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to