accounts/forms.py
def email_token(self, user):
        """Generate activation email and to user else write to file."""
        token = default_token_generator.make_token(user)
        uid = urlsafe_base64_encode(force_bytes(user.pk))
        subject = 'Account Activation - Enstitute'
        text_content = 'You have registered for an account with Enstitute.'
        activation_link = 'http://{0}/accounts/user/validate/{1}/{2}'.format(
            self.host, force_text(uid), token)
        html_content = '<p>Click --><a href="%s" rel="nofollow">here</a><-- to activate your account.</p>' % activation_link
        from_email = getattr(settings, 'EMAIL_HOST_USER', None)
        to_email = user.email
        message = EmailMultiAlternatives(
            subject, text_content, from_email, [to_email])
        message.attach_alternative(html_content, 'text/html')
        try:
            message.send()
        except socket.error as socket_err:
            filename = user.username + '_activation_fail'
            with open(os.path.join(os.getcwd(), filename), 'w+') as fn:
                fn.write('email: \t\t\t\t' + str(user.email) + '\nactivation link: \t' +
                         str(activation_link) + '\nerror: \t\t\t\t' + str(socket_err))
                fn.close()
Generate activation email and to user else write to file.
Generate activation email and to user else write to file.
Generate activation email and to user else write to file .
def email_token(self, user):
        token = default_token_generator.make_token(user)
        uid = urlsafe_base64_encode(force_bytes(user.pk))
        subject = 'Account Activation - Enstitute'
        text_content = 'You have registered for an account with Enstitute.'
        activation_link = 'http://{0}/accounts/user/validate/{1}/{2}'.format(
            self.host, force_text(uid), token)
        html_content = '<p>Click --><a href="%s" rel="nofollow">here</a><-- to activate your account.</p>' % activation_link
        from_email = getattr(settings, 'EMAIL_HOST_USER', None)
        to_email = user.email
        message = EmailMultiAlternatives(
            subject, text_content, from_email, [to_email])
        message.attach_alternative(html_content, 'text/html')
        try:
            message.send()
        except socket.error as socket_err:
            filename = user.username + '_activation_fail'
            with open(os.path.join(os.getcwd(), filename), 'w+') as fn:
                fn.write('email: \t\t\t\t' + str(user.email) + '\nactivation link: \t' +
                         str(activation_link) + '\nerror: \t\t\t\t' + str(socket_err))
                fn.close()
def email_token ( self , user ) : token = default_token_generator . make_token ( user ) uid = urlsafe_base64_encode ( force_bytes ( user . pk ) ) subject = 'Account Activation - Enstitute' text_content = 'You have registered for an account with Enstitute.' activation_link = 'http://{0}/accounts/user/validate/{1}/{2}' . format ( self . host , force_text ( uid ) , token ) html_content = '<p>Click --><a href="%s" rel="nofollow">here</a><-- to activate your account.</p>' % activation_link from_email = getattr ( settings , 'EMAIL_HOST_USER' , None ) to_email = user . email message = EmailMultiAlternatives ( subject , text_content , from_email , [ to_email ] ) message . attach_alternative ( html_content , 'text/html' ) try : message . send ( ) except socket . error as socket_err : filename = user . username + '_activation_fail' with open ( os . path . join ( os . getcwd ( ) , filename ) , 'w+' ) as fn : fn . write ( 'email: \t\t\t\t' + str ( user . email ) + '\nactivation link: \t' + str ( activation_link ) + '\nerror: \t\t\t\t' + str ( socket_err ) ) fn . close ( )
Generate activation email and to user else write to file.
Generate activation email and to user else write to file .
"""Generate activation email and to user else write to file."""
self
user