Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updated geocoder.

  • Loading branch information...
commit 69d5e8203de587db0edb122458f89a17c7585baa 1 parent 56c71e3
@s1ider authored
Showing with 4 additions and 3 deletions.
  1. +4 −3 flats/views.py
  2. BIN  flats/views.pyc
View
7 flats/views.py
@@ -3,7 +3,7 @@
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':
@@ -11,12 +11,13 @@ def search(request):
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
BIN  flats/views.pyc
Binary file not shown
Please sign in to comment.
Something went wrong with that request. Please try again.