The Wayback Machine - https://web.archive.org/web/20220528164323/https://github.com/cookiecutter/cookiecutter-django/issues/2560
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

django.core.exceptions.ImproperlyConfigured: Set the SENDGRID_GENERATE_MESSAGE_ID environment variable #2560

Open
charleshan opened this issue Apr 25, 2020 · 2 comments

Comments

@charleshan
Copy link
Contributor

@charleshan charleshan commented Apr 25, 2020

What happened?

Error while deploying to production: django.core.exceptions.ImproperlyConfigured: Set the SENDGRID_GENERATE_MESSAGE_ID environment variable

It looks like non-essential env config was added without defaults.

What should've happened instead?

Deploy without errors

Solution

Add defaults to Sendgrid config.
Change the following:

ANYMAIL = {
    "SENDGRID_API_KEY": env("SENDGRID_API_KEY"),
    "SENDGRID_GENERATE_MESSAGE_ID": env("SENDGRID_GENERATE_MESSAGE_ID",
    "SENDGRID_MERGE_FIELD_FORMAT": env("SENDGRID_MERGE_FIELD_FORMAT"),
    "SENDGRID_API_URL": env("SENDGRID_API_URL", default="https://api.sendgrid.com/v3/"),
}

To:

ANYMAIL = {
    "SENDGRID_API_KEY": env("SENDGRID_API_KEY"),
    "SENDGRID_GENERATE_MESSAGE_ID": env("SENDGRID_GENERATE_MESSAGE_ID", default=True),
    "SENDGRID_MERGE_FIELD_FORMAT": env("SENDGRID_MERGE_FIELD_FORMAT", default=None),
    "SENDGRID_API_URL": env("SENDGRID_API_URL", default="https://api.sendgrid.com/v3/"),
}
@Andrew-Chen-Wang
Copy link
Contributor

@Andrew-Chen-Wang Andrew-Chen-Wang commented Apr 25, 2020

@charleshan I can make a patch. For the SENDGRID_MERGE_FIELD_FORMAT , it says it's for legacy SendGrid. Perhaps it's best if that's removed instead? https://anymail.readthedocs.io/en/stable/esps/sendgrid/#settings

@browniebroke
Copy link
Member

@browniebroke browniebroke commented Nov 29, 2021

For the SENDGRID_MERGE_FIELD_FORMAT , it says it's for legacy SendGrid. Perhaps it's best if that's removed instead?

Agree, let's drop it 👍🏻

Do we need SENDGRID_GENERATE_MESSAGE_ID? This seems optional as well and will default to True if not specified.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
3 participants