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"<[email protected]>写道:
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
[email protected].
To post to this group, send email to [email protected].
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.
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 [email protected].
To post to this group, send email to [email protected].
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.
For more options, visit https://groups.google.com/d/optout.