cookiecutter-django
cookiecutter-django copied to clipboard
django.core.exceptions.ImproperlyConfigured: Set the SENDGRID_GENERATE_MESSAGE_ID environment variable
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/"),
}
@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
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.
Hi, is this issue still open? i'd to make my first contribution
@rakhazachrie Sure, please do. By the way, no need to ask for permissions, any open issue is up for grab 😉
If an open issue looks no longer valid, making a comment to state it explaining why is also super valuable.
@browniebroke Please assign this issue to me. I am happy to work on this :)
Again, no need to "assign" the issue to anyone. If you want to fix it, send us a pull request with the changes.
Hi @browniebroke , I have created a pull request with the changes : https://github.com/cookiecutter/cookiecutter-django/pull/3885
Checklist:
- I have removed environment variable SENDGRID_MERGE_FIELD_FORMAT from \cookiecutter-django{{cookiecutter.project_slug}}\config\settings\production.py
- I will still need someone to test it or let me know how can I test this as it's an issue that was caused during production deployment using Sendgrid
- I ran tox command to run the default tests and they completed successfully.