Python, Django, Django Rest Framework, Backend, Programming.
timezone.now() < user.otp_max_out: return Response( "Max OTP try reached, try after an hour", status=status.HTTP_400_BAD_REQUEST, ) # Generate OTP and update user record otp = random.randint(1000, 9999) otp_expiry = timezone.now() + datetime.timedelta(minutes=10) max_otp_try = int(user.max_otp_try)