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.