Notifications
Clear all
Building a Multivendor Marketplace Platform with Python Django
3
Posts
2
Users
0
Reactions
13
Views
0
30/01/2025 5:33 am
Topic starter
/// utils.py ///
# accounts/utils.py
from django.contrib.sites.shortcuts import get_current_site
from django.template.loader import render_to_string
from django.utils.http import urlsafe_base64_encode
from django.utils.encoding import force_bytes
from django.contrib.auth.tokens import default_token_generator
from django.core.mail import EmailMessage
def detectUser(user):
if user.role == 1:
redirectUrl = 'vendorDashboard'
return redirectUrl
elif user.role == 2:
redirectUrl = 'custDashboard'
return redirectUrl
elif user.role == Noneand user.is_superadmin:
redirectUrl = '/admin'
return redirectUrl
def send_verification_email(request, user):
current_site = get_current_site(request)
mail_subject = 'Please activate your account'
message = render_to_string('accounts/emails/account_verification_email.html', {
'user': user,
'domain': current_site,
'uid': urlsafe_base64_encode(force_bytes(user.pk)),
'token': default_token_generator.make_token(user),
})
to_email = user.email
mail = EmailMessage(mail_subject, message, to=[to_email])
mail.send()
///Error messages from browser//
C:\Users\Yanga\Desktop\GAAS\accounts\views.py
, line 58, in registerUser-
user = User.objects.create_user(first_name=first_name, last_name=last_name, username=username, email=email, password=password)
-
user.role = User.CUSTOMER
-
user.save()
-
-
#Send verification email
-
mail_subject = 'Please activate your account'
-
email_template = 'accounts/emails/account_verification_email.html'
-
send_verification_email(request, user) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
…
-
messages.success(request, "Your account has been registered successfully!")
-
return redirect('registerUser')
-
else:
-
print('invalid form')
-
print(form.errors)
-
else:
C:\Users\Yanga\Desktop\GAAS\accounts\utils.py
, line 32, in send_verification_email
-
'user': user,
-
'domain': current_site,
-
'uid': urlsafe_base64_encode(force_bytes(user.pk)),
-
'token': default_token_generator.make_token(user),
-
})
-
to_email = user.email
-
mail = EmailMessage(mail_subject, message, to=[to_email])
-
mail.send()
This topic was modified 5 days ago by Ibrahim Salami
3 Answers
0
30/01/2025 6:39 am
Topic starter
0
31/01/2025 5:45 pm
Hi Ibrahim Salami ,
The issue you are facing occurs when your SMTP configuration is incorrect. Please check your SMTP settings to ensure they are correct. Additionally, the GitHub repository link you provided is incorrect.
If you are unable to fix the issue, please provide a screenshot of your SMTP configuration and share a ZIP file link to your project so we can assist you in resolving the problem.
0
01/02/2025 12:20 am
Topic starter
An invitation has been sent to you as collaborator on the repository.
Thanks