27👍
✅
That is the way to do it, the problem here, is that your requested user does not exist. If you want to handle this case, use this:
try:
user_id = int(request.POST['id'])
user = User.objects.get(id=user_id)
except User.DoesNotExist:
//handle the case when the user does not exist.
Also, you need transform your id to Int
.
👤levi
Source:stackexchange.com