werkzeug.url_encode(obj, charset='utf-8', encode_keys=False, sort=False, key=None, separator='&')[source]

URL encode a dict/MultiDict. If a value is None it will not appear in the result string. Per default only values are encoded into the target charset strings. If encode_keys is set to True unicode keys are supported too.

If sort is set to True the items are sorted by key or the default sorting algorithm.

New in version 0.5: sort, key, and separator were added.

  • obj – the object to encode into a query string.
  • charset – the charset of the query string.
  • encode_keys – set to True if you have unicode keys. (Ignored on Python 3.x)
  • sort – set to True if you want parameters to be sorted by key.
  • separator – the separator to be used for the pairs.
  • key – an optional function to be used for sorting. For more details check out the sorted() documentation.