Hello, this is a Django related question. I have an invoice that I have created from a database which displays the information. Now I want to know is if I can send these details to an email address. I have tried looking at this page at http://docs.djangoproject.com/en/dev/topics/email/, but I don't know if I am looking for that. I am assuming I need to create a form maybe as well.
Edit: I want something like this - but I want to return the whole form. Not just the subject. Check the views. Apologies for the late reply.
# urls.py
urlpatterns = patterns('',
(r'^index/add_invoice/$', add_invoice),
(r'^index/invoice/$', invoice_info),
(r'^index/invoice_details/(?P<id>\d+)/$', invoice_details),
)
#views.py
@login_required
def add_invoice(request):
if request.method == 'POST':
form = InvoiceForm(request.POST or None)
if form.is_valid():
form.save()
send_mail('Subject here', 'Here is the message.', '[email protected]', ['[email protected]'], fail_silently=False
)
return HttpResponseRedirect('/index/invoice/')
else:
form = InvoiceForm()
return render_to_response('add_invoice.html', {'form': form}, context_instance=RequestContext(request))
#add_invoice.html
{% extends "base.html" %}
{% block content %}
<font face="verdana,news gothic,arial,heltevica,serif">
<h3> Add Invoice</h3>
<font face="verdana,news gothic,arial,heltevica,serif">
<form method= "POST" action="">
<div id="form">
<table>
{{form.as_table}}
</table>
<div align="center" STYLE=" margin-right:270px">
<input type="submit" value="Submit" STYLE="background-color:#E8E8E8; color:#181818 "/>
</div>
</div>
</form>
{% endblock %}