Timeout error in send_mail function

2022-06-23 Thread Sona Sivasundari
Hi.
I'm working on a project with django and django rest framework.
In one of my views, I tried implementing a simple send_mail, but it gives 
me a TimeOut error. I configured the settings (Email backend as smtp, email 
host, password, ...), and also alowed my email to accept 'less secured 
apps',  but it doesn't seem to work.
I also tried the port 25, 587 and 465. None of that seem to work.

Here is the error:
[WinError 10060] A connection attempt failed because the connected party 
did not properly respond after a period of time, or established connection 
failed because connected host has failed to respond

Can someone please help?
Thanks in advance. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/6b07847d-5731-4637-b054-64f607cbeb8an%40googlegroups.com.


Data not uploading in Django

2022-06-25 Thread Sona Sivasundari
Hello!
I've tried uploading the data I'm entering in the webpage to the database, 
but the data is not entering. Since I am new to django, I don't know what 
the error is. Can anyone please help me? I am using Mysql database.

*My views.py:*

*from django.views.generic import FormView, TemplateView*
*from .forms import EmailForm*
*from django.urls import reverse_lazy*
*from mailapp.models import Email*
*from django.shortcuts import render*

*class MailView(FormView):*
*template_name = 'index.html'*
*form_class = EmailForm*
*success_url = reverse_lazy('mailapp:success')*

*def form_valid(self, form):*
*# Calls the custom send method*
*form.send()*
*return super().form_valid(form)*

*def registered(request):*
*if request.method == 'POST':*
*if request.POST.get('name') and request.POST.get('email') and 
request.POST.get('inquiry') and request.POST.get('message'):*
*mail = Email()*
*mail.name = request.POST.get('name')*
*mail.email = request.POST.get('email')*
*mail.inquiry = request.POST.get('inquiry')*
*mail.message = request.POST.get('message')*
*mail.save() *
*return render(request, 'success.html')*
*else:*
*return render(request, 'success.html')*

*class MailSuccessView(TemplateView):*
*template_name = 'success.html'*

*models.py*

*from django.db import models*
*from django.contrib.auth.models import User*

*class Email(models.Model):*

*name = models.CharField(max_length=120)*
*email = models.EmailField()*
*inquiry = models.CharField(max_length=70)*
*message = models.CharField(max_length=300)*

*def __str__(self):*
*return self.name*

*admin.py*

*from django.contrib import admin*
*from .models import Email*
*admin.site.register(Email)*


Thank you in advance!!

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a4c11360-6516-4d3e-8e82-f42adc70587en%40googlegroups.com.