{ "info": { "author": "Rhys Gibbs", "author_email": "development@rhysgibbs.co.uk", "bugtrack_url": null, "classifiers": [ "Environment :: Web Environment", "Framework :: Django", "Framework :: Django :: 2.2", "Intended Audience :: Developers", "License :: OSI Approved :: BSD License", "Operating System :: OS Independent", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.4", "Programming Language :: Python :: 3.5", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content" ], "description": "# Django HTML Email Templates\n\nA Django app for allowing users to create html emails using Django template variables\npassed in to the context.\n\n\n## Installation\n\nUse the package manager [pip](https://pip.pypa.io/en/stable/) to install django-html-emailtemplates.\n\n pip install django-html-emailtemplates\n\nAdd the package to your INSTALLED_APPS\n\n INSTALLED_APPS = [\n ...\n 'emailtemplates',\n ...\n ]\n\n\n## Usage\n\n # models.py\n from emailtemplates.fields import EmailTemplateField\n class Settings(models.Model):\n contact_form_reply = EmailTemplateField(\n models.SET_NULL,\n null=True,\n email_context=\"\"\"\n You can use the following variables in the template:\n {{ name }}\n {{ subject_matter }}\n {% for item in items %}\n Possible values are:\n {{ item.title }}\n {{ item.cost }}\n {{ item.description }}\n {% endfor %}\n \"\"\"\n )\n\n # views.py\n from emailtemplates.utils import send_email_template\n from emailtemplates.models import EmailTemplate\n from .models import Settings\n\n # view definition\n def form_valid(self, form):\n enquiry = form.save()\n # send reply email to website user\n send_email_template(\n Settings.objects.first().contact_form_reply,\n [enquiry.email],\n {\n 'name': enquiry.name,\n 'subject_matter': enquiry.subject,\n 'items': [\n {\n 'title': 'Product',\n 'cost': '£20.00',\n 'description': 'Product description...'\n }\n ]\n }\n )\n # send notification to website owner\n send_email_template(\n EmailTemplate(\n subject='Enquiry from example.com',\n content='''
There was an enquiry on your website, the details are below:
\n| Name: | \n{{ enquiry.name }} | \n