def address_search(request): if request.method=="POST" and request.POST['query']: results=search(request.POST['query']) if not results: return JsonResponse({'error':"No matching address!"}) elif len(results)==1: searchResult=jsonGen(results[0]) if searchResult: return render(request,'floodextent/property.json',{'feature':searchResult},content_type="application/json") else: return JsonResponse({'error':"No record!"}) else: return JsonResponse({'results':results},safe=False) elif request.method=="GET": requestProp={} requestProp['postcode']=request.GET['postcode'] requestProp['formatted_address']=request.GET['formatted_address'] requestProp['location']={'lng':float(request.GET['lng']),'lat':float(request.GET['lat'])} searchResult=jsonGen(requestProp) if searchResult: return render(request,'floodextent/property.json',{'feature':searchResult},content_type="application/json") else: return JsonResponse({'error':"No record!"})
def testjson(address): temp = get_template('floodextent/property.json') features = jsonGen(address) text = temp.render(Context({"features": features, "errors": []})) print text json.loads(text)
def testjson(address): temp=get_template('floodextent/property.json') features=jsonGen(address) text=temp.render(Context({"features":features,"errors":[]})) print text json.loads(text)