Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Hi! I am supposed to make a link that refers to my registration page, below is my code so far. What does it take for
Hi! I am supposed to make a link that refers to my registration page, below is my code so far. What does it take for it to work
import hashlib import secrets from django.shortcuts import render from coombboom.settings import EMAIL_HOST_USER from . import forms from django.core.mail import send_mail def invitation(request): sub = forms.Invitation() if request.method == 'POST': sub = forms.Invitation(request.POST) referer = request.user.email recepient = str(sub['Email'].value()) referral_token = secrets.token_hex(8) + referer + recepient referral_token = hashlib.sha256(referral_token.encode('utf-8')).hexdigest() subject = 'Welcome' message = 'Here is your link to register: http://127.0.0.1:8000/account/register/token={}'.format(referral_token) print(referral_token) send_mail(subject, message, EMAIL_HOST_USER, [recepient], fail_silently = False) return render(request, 'invitation/success.html', {'recepient': recepient}) return render(request, 'invitation/index.html', {'form':sub})
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started