cookiecutter-django icon indicating copy to clipboard operation
cookiecutter-django copied to clipboard

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

Open charleshan opened this issue 4 years ago • 3 comments

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 avatar Apr 25 '20 00:04 charleshan

@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

Andrew-Chen-Wang avatar Apr 25 '20 03:04 Andrew-Chen-Wang

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.

browniebroke avatar Nov 29 '21 11:11 browniebroke

Hi, is this issue still open? i'd to make my first contribution

rakhazachrie avatar Sep 09 '22 01:09 rakhazachrie

@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 avatar Sep 24 '22 13:09 browniebroke

@browniebroke Please assign this issue to me. I am happy to work on this :)

krati5 avatar Sep 28 '22 16:09 krati5

Again, no need to "assign" the issue to anyone. If you want to fix it, send us a pull request with the changes.

browniebroke avatar Sep 28 '22 16:09 browniebroke

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.

krati5 avatar Sep 28 '22 16:09 krati5