I have a Django app deployed on Pythonanywhere. Everything works as expected except for the verification emails.When a new user registers, he should receive a verification email, but Django doesn't send it until the admin panel is reloaded. All other emails(welcome emails, contact form emails) are sent without issue. When I test locally on my laptop verification emails are sent instantly. I am using django-email-verification and emails are sent through gmail.
views.py
class RegisterView(CreateView):
form_class = RegisterForm
template_name = 'common/register.html'
success_url = reverse_lazy('login')
def dispatch(self, request, *args, **kwargs):
if request.user.is_authenticated:
return redirect('index')
return super().dispatch(request, *args, **kwargs)
def form_valid(self, form):
form.save(commit=False)
user_email = form.cleaned_data['email']
user_username = form.cleaned_data['username']
user_password = form.cleaned_data['password1']
user = UserModel.objects.create_user(username=user_username, email=user_email, password=user_password)
user.is_active = False
send_email(user)
return HttpResponseRedirect(reverse('email sent'))
def form_invalid(self, form):
return super().form_invalid(form)