I need some help sending and verifying OTP in Django. am trying to add 2FA to my authentication module and I came across a package called pyotp that helps generate and verify OTP. The good thing is that am able to use this package to generate OTP but my problem is how to verify this OTP if expired or incorrect when I prompt the user to supply the otp sent to his/her phone or mail. the below code is what I have implemented from the doc but I don't know why the verification part ain't working. I could actually verify manually but that wont tell me if OTP has expired or not and i don't also know how to expire OTP after a particular time
TO GENERATE OTP
import pyotp
base32secret3232 = pyotp.random_base32()
otp = pyotp.TOTP(base32secret3232)
time_otp = otp.now()
user.otp = time_otp
user.save()
TO VERIFY OTP
if totp.verify(otp):
user.is_verified = True
user.save()