Skip to content

Unable to use extends template tag in Djoser emails #860

Open
@stefanofusai

Description

@stefanofusai

Dear team,
I'm looking to using the extends template tag in my emails, but to no success.

My base.html looks like this:

{% autoescape off %}
    <!DOCTYPE html>
    <html lang="en">
        <head>
            <meta charset="UTF-8" />
            <meta name="viewport" content="width=device-width, initial-scale=1.0" />
            <title>{% block title %}{% endblock %}</title>
        </head>
        <body
           ...
                        {% block content %}
                        {% endblock %}
        </body>
    </html>
{% endautoescape %}

My password_reset.html looks like this:

{% extends "core/base.html" %}

{% block subject %}
    ...
{% endblock %}

{% block text_body %}
    ...
{% endblock %}

{% block title %}
    ...
{% endblock %}

{% block content %}
    ...
{% endblock %}

My emails.py:

class PasswordResetEmail(BasePasswordResetEmail):
    template_name = "core/emails/password_reset.html"

All I get when sending the email is this error:

anymail.exceptions.AnymailRequestsAPIError: Resend API response 422 (Unprocessable Entity):
{
  "name": "validation_error",
  "statusCode": 422,
  "message": "Missing `html` or `text` field."
}

I investigated and it seems like self.body is being set to an empty string and self.html is being set to None.
Any idea of what I'm doing wrong? Thanks!

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions