So I'm learning to create a confirmation email address while registering an account using Django

This is `from django.contrib import admin from django.urls import path, include from . import views

urlpatterns = [
path('', views.home, name="home"),
path('signup', views.signup, name="signup"),
path('activate/<uidb64>/<token>', views.activate, name="activate"),
path('signin', views.signin, name="signin"),
path('signout', views.signout, name="signout"),

This is

myuser = User.objects.create_user(username, email, pass1)
    myuser.first_name = fname
    myuser.last_name = lname
    myuser.is_active = False
    messages.success(request, "Hey, Your Account has been successfully created. We have sent you a  confirmation email. Please confirm your email in order to activate your account.")

    #welcome email
    subject = "Welcome to Django Login Project!!"
    message = "Hello" + myuser.first_name + " !! \n" + "Welcome to Django Login Project!! \n Thank You for visiting our website \n We have sent you a confirmation email, Please confirm your email address in order to activate your account. \n\n Thanking You\n Shalini Singh"
    from_email = settings.EMAIL_HOST_USER 
    to_list = []
    send_mail(subject, message, from_email, to_list, fail_silently= True )

    #email address confirmation

    current_site = get_current_site(request)
    email_subject = "Confirm your email @ Login Django Project!!"
    message2 = render_to_string('email_confirmation.html',{
    'name' : myuser.first_name,
    'domain' : current_site.domain,
    'uid' : urlsafe_base64_encode(force_bytes(,
    'token' : generate_token.make_token(myuser)

     email = EmailMessage(
     email.fail_silently = True
     return redirect('signin')
     return render(request, "authentication/signup.html")

     def activate(request, uidb64, token):
     uid = force_str(urlsafe_base64_encode)(uidb64)
     myuser = User.objects.get(pk=uid)
     except (TypeError, ValueError, OverflowError, User.DoesNotExist):
     myuser = None

     if myuser is not None and generate_token.check_token(myuser, token):
     myuser.is_active = True
     login(request, myuser)
     return redirect('home')

     return render(request, 'activation_failed.html')


This is

from django.contrib.auth.tokens import PasswordResetTokenGenerator

    from six import text_type

    class TokenGenerator(PasswordResetTokenGenerator):
    def _make_hash_value(self, user, timestamp):
    return (
    text_type( + text_type(timestamp)

    generate_token = TokenGenerator()

This is email_confirmation.html `

{% autoescape off %}
     Welcome to Django Login Project
     Hello {{ name }}!!
     Please confirm your email by clicking on following link.
     Confirmation Link: http://{{ domain }}{% url 'activate' uidb64=uid token=token %}
     {% endautoescape %}``

This is activation_failed.html

`{% autoescape off %}

Activation failed, Please try later!

{% endautoescape %}

Probmem is i can not activate account. `

When i signup i got this mail

Welcome to Django Login Project Hello Shalini!! Please confirm your email by clicking on following link. Confirmation Link:

and when i click the link show-

Activation failed, Pleae try later!

Back to Top