On Thu, 2007-05-03 at 15:43 +0000, simonbun wrote:
> Suppose the following query parameters:
> myurl/?var=1&var=2&var=3
> 
> Running this through QueryDict correctly gives me
> <MultiValueDict: {'var': ['1', '2', '3']}>
> 
> I had hoped that multiple levels in these variables would result in a
> nested dictionary, but no such luck. To illustrate the problem lets
> suppose the following query:
> 
> myurl/?
> countries[visited]=us&countries[visited]=dk&countries[notvisited]=be
> 
> It gets parsed as
> <MultiValueDict: {'countries[visited]': ['us', 'dk'],
> 'countries[notvisited]': ['be']}>
> 
> yet i would have hoped:
> <MultiValueDict: {'countries': {'visited': ['us', 'dk'], 'notvisited':
> ['be']}}>
> 
> 
> I'm thinking it would be better to have QueryDict recurse through the
> values instead of just parsing one level deep. Is there a way to
> achieve what I want, or is this handled at the mod_python level?

Trying to impose Python syntax on URLs doesn't seem like a good idea to
me (it leads to somewhat opaque URLs, for a start). Presumably you are
talking about this more in the sense of form submission, so let's think
of it as POST data, rather than URLs.

You could write a function that takes Django's standard MultiValueDict
and returns the type of nested structure you are after. Not a change
worth making in core, but it's only a function you would have to write
once for your own use.

Regards,
Malcolm



--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to