Skip to content

Commit

Permalink
Cleaned up EmailMultiAlternatives docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
sarahboyce committed Jun 21, 2024
1 parent 20c2d62 commit 7a0cd09
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions docs/topics/email.txt
Original file line number Diff line number Diff line change
Expand Up @@ -397,11 +397,27 @@ Django's email library, you can do this using the

.. class:: EmailMultiAlternatives

A subclass of :class:`~django.core.mail.EmailMessage` that allows
additional versions of the message body in the email via the
``attach_alternative()`` method. This directly inherits all methods
(including the class initialization) from
:class:`~django.core.mail.EmailMessage`.
A subclass of :class:`EmailMessage` that allows additional versions of the
message body in the email via the :meth:`attach_alternative` method. This
directly inherits all methods (including the class initialization) from
:class:`EmailMessage`.

.. attribute:: alternatives

A list of named tuples with attributes ``(content, mimetype)``. This is
particularly useful in tests::

self.assertEqual(len(msg.alternatives), 1)
self.assertEqual(msg.alternatives[0].content, html_content)
self.assertEqual(msg.alternatives[0].mimetype, "text/html")

Alternatives should only be added using the :meth:`attach_alternative`
method.

.. versionchanged:: 5.2

In older versions, ``alternatives`` was a list of regular tuples,
as opposed to named tuples.

.. method:: attach_alternative(content, mimetype)

Expand All @@ -420,24 +436,6 @@ Django's email library, you can do this using the
msg.attach_alternative(html_content, "text/html")
msg.send()

.. attribute:: alternatives

A list of named tuples with attributes ``(content, mimetype)``. This is
particularly useful in tests::

self.assertEqual(len(msg.alternatives), 1)
self.assertEqual(msg.alternatives[0].content, html_content)
self.assertEqual(msg.alternatives[0].mimetype, "text/html")

Alternatives should only be added using the
:meth:`~django.core.mail.EmailMultiAlternatives.attach_alternative`
method.

.. versionchanged:: 5.2

In older versions, ``alternatives`` was a list of regular tuples, as opposed
to named tuples.

Updating the default content type
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Expand Down

0 comments on commit 7a0cd09

Please sign in to comment.