@staticmethod
def post(request, *args, **kwargs):
constant = utils.send_grid_key
sg = SendGridAPIClient(constant)
subject = get_subject()
content = get_content()
message = Mail(
from_email=From((utils.sender_mail, 'Hello')),
to_emails=To('mani...@gmail.com'),
# to_emails=To(get_email()),
subject=subject,
html_content=content)
response = sg.send(message)
print(response.status_code)
print(response.body)
print(response.headers)
return Response(response)
Traceback (most recent call last):
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\core\handlers\exception.py",
line 55, in inner
response = get_response(request)
^
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\core\handlers\base.py",
line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\views\decorators\csrf.py",
line 54, in wrapped_view
return view_func(*args, **kwargs)
^^
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\views\generic\base.py",
line 103, in view
return self.dispatch(request, *args, **kwargs)
^^^
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
line 509, in dispatch
response = self.handle_exception(exc)
^^
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
line 469, in handle_exception
self.raise_uncaught_exception(exc)
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
line 480, in raise_uncaught_exception
raise exc
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
line 506, in dispatch
response = handler(request, *args, **kwargs)
^
File "C:\Users\Lenovo\marketautomation\automation\user\views.py", line
140, in post
message = Mail(
^
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\sendgrid\helpers\mail\mail.py",
line 80, in __init__
self.add_content(html_content, MimeType.html)
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\sendgrid\helpers\mail\mail.py",
line 734, in add_content
if content.mime_type == MimeType.text:
^
AttributeError: 'QuerySet' object has no attribute 'mime_type'
[19/Jan/2023 17:54:52] ERROR - Internal Server Error: /automation/user/mail
Traceback (most recent call last):
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\core\handlers\exception.py",
line 55, in inner
response = get_response(request)
^
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\core\handlers\base.py",
line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\views\decorators\csrf.py",
line 54, in wrapped_view
return view_func(*args, **kwargs)
^^
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\django\views\generic\base.py",
line 103, in view
return self.dispatch(request, *args, **kwargs)
^^^
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
line 509, in dispatch
response = self.handle_exception(exc)
^^
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
line 469, in handle_exception
self.raise_uncaught_exception(exc)
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
line 480, in raise_uncaught_exception
raise exc
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\rest_framework\views.py",
line 506, in dispatch
response = handler(request, *args, **kwargs)
^
File "C:\Users\Lenovo\marketautomation\automation\user\views.py", line
140, in post
message = Mail(
^
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\sendgrid\helpers\mail\mail.py",
line 80, in __init__
self.add_content(html_content, MimeType.html)
File
"C:\Users\Lenovo\marketautomation\venv\Lib\site-packages\sendgrid\helpers\mail\mail.py",
li