Python Forum

Full Version: sending email from admin to user in django
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
i want to send email from admin to user .my code get no reverse match error.
views.py

def emails(request,id):
subject = 'leave confirmation'
message = ' your leav application approved'
email_from = settings.EMAIL_HOST_USER
x=leavdb11.objects.all()
for i in x:
if i.id==int(id):
recipient_list = [i.email,]
send_mail( subject, message, email_from,recipient_list)
return HttpResponse("send")
urls.py
url(r'^emails/(\d+)/',emails,name='emails'),

html
<body>
<a href="{% url 'emails' %} ">send mail</a>
</body>

forms.py
class ButtonWidget(forms.Widget):
template_name = 'auth_button_widget.html'
def renders(self, name, value, attrs=None):
context = {
'url': '/',

}
return mark_safe(render_to_string(self.template_name, context))

class leavapprv(forms.ModelForm):
button = forms.CharField(widget=ButtonWidget)


class Meta:
model = leavdb11
fields = "__all__"