Note that there are some explanatory texts on larger screens.

plurals
  1. POdjango: sending unicode address to googmaps from form
    primarykey
    data
    text
    <p>i'm using <strong>googlemaps</strong> <a href="http://py-googlemaps.sourceforge.net/" rel="nofollow">http://py-googlemaps.sourceforge.net/</a> to show some travel info. i send <strong>start_address</strong> and <strong>end_address</strong> through a form and calculate route server-side.</p> <p>everything works fine when i use basic ascii charaters in address, but if i use wild croatian characters such as <em>'čćšž'</em> i get <em>"'ascii' codec can't encode character u'\u010d' in position...".</em> </p> <p>if i use </p> <pre><code>from googlemaps import GoogleMaps directions = GoogleMaps().directions(smart_str(start_address), smart_str(end_address)) </code></pre> <p>as a command <strong>in shell it runs fine</strong>, but not when i run through test server on the website. start_address and end_address are both type unicode.</p> <p>so how am i suppost to form start_address in order for it to function properly with whole unicode?</p> <p><strong>Edit:</strong></p> <p>after fiddling around some more this is the code that finally works:</p> <pre><code>from django.shortcuts import render_to_response from django.utils.encoding import smart_unicode, smart_str from googlemaps import GoogleMaps def calculations(request): if request.method == 'POST': trip = {} start_address = smart_str(request.POST.get('start_address')) end_address = smart_str(request.POST.get('end_address')) directions = GoogleMaps().directions(start_address, end_address) trip['length'] = directions['Directions']['Distance']['html'] trip['duration'] = directions['Directions']['Duration']['html'] return render_to_response( 'index.html', {'trip':trip, }, context_instance = RequestContext(request) ) </code></pre> <p>you can consider the issue closed :)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload