Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use extends template tag in Djoser emails #860

Open
stefanofusai opened this issue Jan 14, 2025 · 0 comments
Open

Unable to use extends template tag in Djoser emails #860

stefanofusai opened this issue Jan 14, 2025 · 0 comments

Comments

@stefanofusai
Copy link

stefanofusai commented Jan 14, 2025

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!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant