Thursday, March 26, 2015

Re: QueryDict and its .dict() method - why does it do that?

On Thursday, 26 March 2015 17:52:48 UTC, Gabriel Pugliese wrote:
This gist is self informative - some information from list is lost: https://gist.github.com/gabrielhpugliese/640b69eefc5b7490a07c

Some of my buddies have pasted Rails(Rack) and PHP conversion right below. Is that something I am missing? Does it have to do with laziness?

Because Django is not Rails or PHP.

The [] convention is not a standard part of HTTP. I believe it was developed in PHP and DHH adopted it for Rails, but that doesn't make it a standard. Django does not expect data in that format and does not do any specific conversion for it.

The way to provide multiple values for an item in Django is by simply repeating the name:
    ?categories=1&categories=3
which you can then get from the querydict via `request.getlist('categories')
--
Daniel.

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
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/be0e9769-0605-445b-9993-7470f0374e28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment