1π
β
It depends on which REST method do you want to call it. If you are using simple GET
, then call it in get()
like this:
class VerifyCode(FormView):
template_name = "account/verify.html"
form_class = VerifyForm
def random_code(self):
#random_code generator
return random_code
def send_email(self):
#code to send email
def get(self, request, *args, **kwargs):
...
self.random_code()
self.send_email()
return super().get(request, *args, **kwargs)
In similar way in post()
for POST
method.
Another thing is you can send emails directly with Django
. I do that and itβs pretty simple. Check this DOCS. You can post another question about that if you have something.
π€NixonSparrow
Source:stackexchange.com