Monday, February 2, 2015

Re: sending email

Hi James,

if you have a look at my view.py code below. i am trying to send email to a selected user that i have select to update that particular user using a form. The updated part is working fine now, i can update the particular row that i have selected. what i want to do next is to email that particular user that his data has been updated. i am still very confuse about the email part.
view.py

def coporateservices_authorized_Leave(request, id):
if request.method == 'POST':
a=newleave.objects.get(id=id)
form = coporateservices_authoriseleave(request.POST, instance=a)
if form.is_valid():
form.save()
to_emails = [a.admins.all()]
send_mail("RBV Leave Application Email Testing", "Your Leave have been approved",
"RBV eLeave <Rbv_eLeave_System>", [to_emails])
return render_to_response('thankyou.html')
else:
a=newleave.objects.get(id=id)
form = coporateservices_authoriseleave(instance=a)
return render_to_response('coporate_services_leave_approvial.html', {'form': form}, context_instance=RequestContext(request))


model.py

class newleave(models.Model):
first_name = models.CharField(max_length=45)
last_name =models.CharField(max_length=45)
department=models.CharField(max_length =45)
position=models.CharField(max_length =45)
leave_type =models.CharField(max_length=45)
specify_details=models.TextField(default="")
start_date =models.DateField(null=True)
end_date=models.DateField(null=True)
total_working_days=models.IntegerField(null=True)
department_head_authorization =models.CharField(max_length=45, default ="")
authorized_by=models.CharField(max_length=45, default ="")
remarks=models.TextField()
authorization_date =models.DateField(null=True)
corporate_services_authorization =models.CharField(max_length=45)
authorized_by1=models.CharField(max_length=45)
remarks1=models.TextField(default ="")
authoriztaion1_date =models.DateField(null=True)
total_Leave_Left =models.IntegerField(default=20)
username =models.ForeignKey(User, default =1)










On Mon, Feb 2, 2015 at 8:44 PM, monoBOT <monobot.soft@gmail.com> wrote:

2015-02-02 6:51 GMT+01:00 sum abiut <suabiut@gmail.com>:

to_emails = [a.admins.all()]

You are asking for item admins here:


to_emails = [a.admins.all()]



--
monoBOT
Visite mi sitio(Visit my site): monobotsoft.es/blog/

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CA%2BxOsGBHGrjKgDV7ZvS%2Bs1EUm571bpQzdGPEn6MGyRKvUqYh2w%40mail.gmail.com.

For more options, visit https://groups.google.com/d/optout.



-

--
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+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAPCf-y48H8FahyqnxD00fA2g%3Dw8OTRQyn7LkN4%2BRhaVbUL1SWQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment