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

Value of USE TEMPLATE in admin is wrong, but template is used #395

Open
Schwankenson opened this issue Mar 22, 2022 · 4 comments
Open

Value of USE TEMPLATE in admin is wrong, but template is used #395

Schwankenson opened this issue Mar 22, 2022 · 4 comments

Comments

@Schwankenson
Copy link

Schwankenson commented Mar 22, 2022

I`m using Version 3.6.0.

I created a email template in database admin. And then sent mail with this command:

        mail.send(
            '[email protected]', # List of email addresses also accepted
            '[email protected]',
            template='user_cancelled_subscription', # Could be an EmailTemplate instance or name
            context={'foo': 'bar'},
        )

Email subject and content is filled with values from the template, everything seems to work fine. But in admin, there is a red cross below USE TEMPLATE:
image

And when I click filter user_cancelled_subscription for the "By Name" filter, the email is not shown.

What could be wrong? This is really confusing.

@Schwankenson
Copy link
Author

Same problem exists with this code:

    mail_template = EmailTemplate.objects.get(id=2)

    mail.send(
        '[email protected]', # List of email addresses also accepted
        '[email protected]',
        template=mail_template, # Could be an EmailTemplate instance or name
        context={'foo': 'bar'},
    )

@Schwankenson
Copy link
Author

Another test:

mail_template = EmailTemplate.objects.get(name="user_cancelled_subscription")

email = mail.send(
    '[email protected]', # List of email addresses also accepted
    '[email protected]',
    template=mail_template, # Could be an EmailTemplate instance or name
    context={'foo': 'bar'},
)

email.template = mail_template
email.save()

Like this, the template is shown in admin and filter works. But the template variables are not filled anymore.

image

@selwin
Copy link
Collaborator

selwin commented Jun 16, 2022

Yeah this seems to be a bug. Mind opening a PR for this? If template is passed to mail.send(), use_template should be True.

@Schwankenson
Copy link
Author

I don`t have the time to fix this and open a PR at the moment...somebody else? Should be easy to fix, right?

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

2 participants