def conctrat_page(request): cli = Climdex("/home/nuyuyii/401_Project/seaclid/ec85indcal.csv") if request.method == 'POST': #POST goes here . is_ajax is must to capture ajax requests. Beginner's pit. txx_data = cli.txx() if request.is_ajax(): #Always use get on request.POST. Correct way of querying a QueryDict. path_file = request.POST.get('path_file') print(path_file) data = {"path_file": getattr(cli, path_file)()} #Returning same data back to browser.It is not possible with Normal submit return JsonResponse(data) return render(request, 'map_Contrast.html')
def home_page(request): cli = Climdex("/home/thiranan/Project2/ec45indcal.csv") cli2 = Indexs() max_data = cli2.max1() aa = getattr(cli2, "su1")() #print(aa) grid_dat = avg_rcp85.objects.get(id=1) sus = grid_dat.index_su print(type(sus)) print(type(aa)) #print(data_p) #cal[x] =cal[x]+su[0][str(2006+x)] grid_dat2 = his_rcp85.objects.get(id=1) ids = [] ids.append(grid_dat2.index_id) print(type(ids)) '''su = [] data_p = [] cal_sum = [] num_point = 10 str_year = 1970 for i in range(0,36): cal_sum.append(0) for x in range(1,num_point):# 48323 grid_dat = his_rcp85.objects.get(id=x) su.append(grid_dat.index_su) for x in range(0,len(grid_dat.index_su)): cal_sum[x] = cal_sum[x] + su[0][str(str_year+x)] for i in range(0,len(cal_sum)): data_p.append([str(str_year+i),cal_sum[i]/num_point])''' if request.method == 'POST': #POST goes here . is_ajax is must to capture ajax requests. Beginner's pit. txx_data = cli.txx() if request.is_ajax(): #Always use get on request.POST. Correct way of querying a QueryDict. path_file = request.POST.get('path_file') #print(path_file) data = {"path_file":getattr(cli2, path_file)()} #Returning same data back to browser.It is not possible with Normal submit print(path_file) print(data) return JsonResponse(data) return render(request, 'map_graph.html',{'Max_ts':json.dumps(max_data)})
def home_page(request): cli = Climdex("/home/thiranan/Project2/ec85indcal.csv") if request.method == 'POST': #POST goes here . is_ajax is must to capture ajax requests. Beginner's pit. txx_data = cli.txx() if request.is_ajax(): #Always use get on request.POST. Correct way of querying a QueryDict. path_file = request.POST.get('path_file') #print(path_file) data = {"path_file": getattr(cli, path_file)()} #Returning same data back to browser.It is not possible with Normal submit return JsonResponse(data) #Get goes here return render(request, 'gridTs.html', {'SU': json.dumps(cli.su())})