Import "sendgrid" could not be resolved django

  1. Make sure you have installed the "sendgrid" package using pip:
pip install sendgrid
  1. Import the SendGridAPIClient and Mail classes in your Django file:
from sendgrid import SendGridAPIClient
from sendgrid.helpers.mail import Mail
  1. Use the SendGridAPIClient to send emails in your Django application:
message = Mail(
    from_email='[email protected]',
    to_emails='[email protected]',
    subject='Subject',
    plain_text_content='Plain Text Content',
    html_content='<strong>HTML Content</strong>'
)

try:
    sg = SendGridAPIClient('SENDGRID_API_KEY')
    response = sg.send(message)
    print(response.status_code)
    print(response.body)
    print(response.headers)
except Exception as e:
    print(e.message)