PHP's form bracket trick is to Django's ___?

Posted by Matt on Stack Overflow See other posts from Stack Overflow or by Matt
Published on 2010-03-26T23:37:15Z Indexed on 2010/03/26 23:43 UTC
Read the original article Hit count: 199

Filed under:
|
|

In PHP you can create form elements with names like:

category[1]
category[2]

or even

category[junk]
category[test]

When the form is posted, category is automatically turned into a nice dictionary like:

category[1] => "the input value", category[2] => "the other input value"

Is there a way to do that in Django? request.POST.getlist isn't quite right, because it simply returns a list, not a dictionary. I need the keys too.

© Stack Overflow or respective owner

Related posts about django

Related posts about php