I'm currently developing an app which requires simple otp authentication using django
In models.py
of an app accounts
I've created a class to store the otp without making it as a model as follows,
class temp:
def __init__(self,otp):
self.otp = otp
print(self.otp)
In views.py
the code goes as,
g = globals()
... some code
g["user"+ str(request.POST['username'])] = models.temp(the_otp)
This works completely fine in localhost
, Will this work if I deploy this to heroku
. If not suggest some other way to store the otp temporarily without making models.
Thanks in advance.
No this will not work fine. You might see it working fine in your local development server but there are several problems this approach faces due to the fact that this is using global variables:
In general global variables are bad more so in a web server.