def locator(request): if request.method != "POST": raise Http404 if ( "lat" not in request.POST or "long" not in request.POST or "acc" not in request.POST or "time" not in request.POST ): raise Http404 location = Location() location.latitude = request.POST.get("lat") location.longitude = request.POST.get("long") location.accuracy = request.POST.get("acc") if "wifissid" in request.POST: location.wifissid = request.POST.get("wifissid") if "gsmtype" in request.POST: if request.POST.get("gsmtype").lower() != "unknown": location.gsmtype = request.POST.get("gsmtype") location.devicetimestamp = datetime.datetime.fromtimestamp(Decimal(request.POST.get("time")) / 1000, tz=utc) location.save() return HttpResponse("")