I got a strange thing I can't handle and understand. I'm really intrigue
Let me explain, I coded some stuff locally on my computer with python3 (which run like a charm !! ), I used to transfer this script to my django . And magic happen it's raised an error , I don't have when I run locally ...
here is the script part which seems to create the error :
from c***.utils import calculate_distance
from operator import itemgetter
import geopy
solution = []
def is_in_radius(elem1, elem2):
dict_coord = {
'pa' : (elem1[3][0],elem1[3][1]),
'pb' : (elem2[3][0],elem2[3][1]),
}
distance = calculate_distance(dict_coord.get('pa'), dict_coord.get('pb'))
# print("distance : " + str(distance) + " m - entre : "+ str(elem1[0]) + " et " + str(elem2[0]))
if (distance <= 1200):
return(True)
else:
return(False)
def last_rad(data_info, elem1, am_act):
global solution
if(len(solution) + 1 == am_act):
if(is_in_radius(elem1, data_info[1]) == True):
return(True)
else:
return(False)
else:
return(True)
def first_rad(data_info, elem1):
global solution
if(len(solution) == 0):
if(is_in_radius(data_info[0], elem1) == True):
return(True)
else:
return(False)
else:
return(True)
Error raised is :
'function' object is not subscriptable
Request Method: POST
Request URL: http://****.io/new_search
Django Version: 3.1
Exception Type: TypeError
Exception Value:
'function' object is not subscriptable
Exception Location: /home/debian/***/mysite/**/backtrack.py, line 33, in first_rad
Python Executable: /usr/bin/python3
Python Version: 3.7.3
line 33 is linked to
if(is_in_radius(data_info[0], elem1) == True):
Does someone have an idea on how to manage the error and when it could coming from ?
Thank's a lot !