Skip to main content

Django application with Bootstrap email template tag.

Project description

django-bootstrap-email

Usage

  1. Install
pip install django-bs-email
  1. Add to INSTALLED_APPS
INSTALLED_APPS = [
    # ...
    "django_bootstrap_email",
]
  1. Use the bootstrap_email template tag in your Django template
{% load bootstrap_email %}

{% bootstrap_email %}
<body class="bg-light">
  <div class="container">
    <div class="card my-10">
      <div class="card-body">
          <p>
            {{ message }}
          </p>
      </div>
    </div>
  </div>
</body>
{% end_bootstrap_email %}
  1. Create the email and send it
context = {
    "message": "Hello World!",
}

# you should always include a plain text version of the HTML email
text_content = context["message"]
html_content = render_to_string("path/to/template.html", context)

email_message = EmailMultiAlternatives(
    subject="Greetings",
    body=text_content,
    from_email="me@test.com",
    to=["you@test.com"],
)
email_message.attach_alternative(html_content, "text/html")
email_message.send()

This will produce a complete HTML email that renders consistently across email clients:

Rendered HTML email example

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django_bs_email-0.2.2.tar.gz (3.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_bs_email-0.2.2-py3-none-any.whl (4.5 kB view details)

Uploaded Python 3

File details

Details for the file django_bs_email-0.2.2.tar.gz.

File metadata

  • Download URL: django_bs_email-0.2.2.tar.gz
  • Upload date:
  • Size: 3.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.0.0 CPython/3.12.3

File hashes

Hashes for django_bs_email-0.2.2.tar.gz
Algorithm Hash digest
SHA256 3074d222642c31dbcd3f263f65a855be3036f69bdd8f555582d59a6229bb4c33
MD5 d0507377810a2ee4cda2e0a4fee3b851
BLAKE2b-256 59421f3261b1d9ebc271d144459d7fbe796fefd01187b7bdcb66c69151938f49

See more details on using hashes here.

File details

Details for the file django_bs_email-0.2.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_bs_email-0.2.2-py3-none-any.whl
Algorithm Hash digest
SHA256 1505a02450d394c14ca590a4d258d49192fd41074aaf3a2b533c152b56992f93
MD5 632959306412c9958372bfb0e676f1e7
BLAKE2b-256 6a2105ffda7d948f1e05604a052318183d9a7bb46077b2d3e1841d1d561b4a39

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page