Python, Django, Django Rest Framework, Backend, Programming.
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) - 1 user.otp = otp user.otp_expiry = otp_expiry user.max_otp_try = max_otp_try if max_otp_try