Hello sir i have in DJANGO a problem tryin to get my algorithm right please help, much appreciated: MYERROR: int() argument must be a string, a bytes-like object or a number, not 'list'
MYCODE:
def subs(request, pk):
sw = Swimmers.objects.filter(id=pk).values('sessions')
sw_list = int(list(sw))
res = sw_list 1
print('Data:',sw)
return JsonResponse(res, safe=False)
CodePudding user response:
You can't convert a list to an int, my suggestion would be:
sw_list = map(int, sw)
This will convert each of the elements of sw
to an int
But you're also going to have issues because you can't increment a list either, so on the very next line you'd need something like:
sw_list = map(lambda x: x 1, sw_list) # instead of sw_list = 1