def post(self, request): data = request.data if not data: data = request.POST queries = [data[p] for p in data if p.startswith('q_')] results = GEO_DAL.geolocate(queries) serializer = LocationSerializer(results, context={'request': request}, many=True) return Response(serializer.data)
def get(self, request): query = request.query_params.get('query', None) if not query: raise ValidationError('query was not provided.') results = GEO_DAL.geolocate([ query, ]) if results: results = results[0] serializer = LocationSerializer(results, context={'request': request}) return Response(serializer.data)