Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Apr 26th, 2012  |  syntax: None  |  size: 0.89 KB  |  hits: 17  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Unicode Error in urllib.urlencode - in my Django Web App
  2. search_form = SearchForm(request.GET)
  3. get_data = dict([(key,item) for (key,item) in search_form.data.items()])
  4. get_params = '&' + urllib.urlencode(query=get_data.items())
  5.        
  6. File "/opt/python/lib/python2.7/site-packages/django/core/handlers/base.py", line 100, in get_response
  7.     response = callback(request, *callback_args, **callback_kwargs)
  8.  
  9.   File "/opt/python/lib/python2.7/site-packages/django/contrib/auth/decorators.py", line 25, in _wrapped_view
  10.     return view_func(request, *args, **kwargs)
  11.  
  12.   File "/opt/DjangoProjects/Fly/FlyStore/views.py", line 465, in search
  13.     get_params = '&' + urllib.urlencode(query=get_data.items())
  14.  
  15.   File "/opt/python/lib/python2.7/urllib.py", line 1282, in urlencode
  16.     v = quote_plus(str(v))
  17.  
  18. UnicodeEncodeError: 'ascii' codec can't encode character u'u2206' in position 15: ordinal not in range(128)