Permalink
Browse files

Updated geocoder.

  • Loading branch information...
1 parent 56c71e3 commit 69d5e8203de587db0edb122458f89a17c7585baa @s1ider committed Nov 25, 2011
Showing with 4 additions and 3 deletions.
  1. +4 −3 flats/views.py
  2. BIN flats/views.pyc
View
@@ -3,20 +3,21 @@
from django.shortcuts import render_to_response
from django.template.response import TemplateResponse
from flats.models import SearchHistory
-import simplejson
+import simplejson, json
def search(request):
if request.method == 'POST':
search_query = request.POST['search']
params = urlencode({
'geocode' : search_query,
'format' : 'json',
- 'api' : u'ALkUyk4BAAAApRinSwIAS_pBYGgk9hlNbOWvjOx3Zi8VGBIAAAAAAAAAAADG1QihAV-jqGTltsWsd3ylJFXKPw=='
+ 'key' : 'ALkUyk4BAAAApRinSwIAS_pBYGgk9hlNbOWvjOx3Zi8VGBIAAAAAAAAAAADG1QihAV-jqGTltsWsd3ylJFXKPw=='
})
response_json = urlopen('http://geocode-maps.yandex.ru/1.x/', params)
- result = simplejson.load(response_json)
+ result = json.load(response_json)
if 'error' in result:
result = "Error has happened: " + result['error']['message']
+ result = result['response']['GeoObjectCollection']['featureMember'][0]['GeoObject']['Point']['pos']
else:
pass
return TemplateResponse(request, 'flats.html', {
View
Binary file not shown.

0 comments on commit 69d5e82

Please sign in to comment.