Can I make Django QueryDict preserve ordering?

QueryDict inherits from Django's MultiValueDict which inherits from dict which is implemented as a hash table. Thus, you can't guarantee it will stay ordered.

I'm not sure if this will be relevant to what you need, but an ordering that QueryDict does preserve is the order of "lists" (multiple values for the same key) passed in to them. Using this, you could do:

>>> from django.http import QueryDict
>>> q = QueryDict(u'x=foo³&x=bar(potato),x=hello world')
>>> q.lists()
[('x', ['foo³', 'bar(potato)', 'hello world'])]
>>> q.urlencode(safe='()')
u'x=foo%C2%B3&x=bar(potato)&x=hello%20world'