I tried to get the latest id in Django but get the error.
def getlatestid(request): cot_info = COT.objects.latest(\'id\') return JsonResponse({\"data\":
latest(...) returns an object, not a list. So, you can try like this to fix the error:
def getlatestid(request): cot_info = COT.objects.values().latest('id') return JsonResponse({"data": cot_info})