Python TypeError,send_mail()缺少1个必需的位置参数:';收件人名单';
我添加了一个布尔值,因此属性标题在前端是不可更改的,但是我得到了这个错误Python TypeError,send_mail()缺少1个必需的位置参数:';收件人名单';,python,django,django-views,Python,Django,Django Views,我添加了一个布尔值,因此属性标题在前端是不可更改的,但是我得到了这个错误 TypeError at /contacts/contact send_mail() missing 1 required positional argument: 'recipient_list' Request Method: POST Request URL: http://127.0.0.1:8000/contacts/contact Django Version: 3.0.4 Exception Type:
TypeError at /contacts/contact
send_mail() missing 1 required positional argument: 'recipient_list'
Request Method: POST
Request URL: http://127.0.0.1:8000/contacts/contact
Django Version: 3.0.4
Exception Type: TypeError
Exception Value:
send_mail() missing 1 required positional argument: 'recipient_list'
views.py
def contact(request):
if request.method == 'POST':
property_id = request.POST['property_id']
if 'property' in request.POST:
property = request.POST['property']
else:
property = False
name = request.POST['name']
email = request.POST['email']
message = request.POST['message']
realtor_email = request.POST['realtor_email']
contact = Contact(property=property, property_id=property_id, name=name, message=message )
contact.save()
# Send Email
send_mail(
'Property Inquiry',
'There has been an inquiry for' + property + 'Check it',
['m@gmail.com', 'j@gmail.com'],
fail_silently=False
)
设置.py
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_HOST_USER = '******@gmail.com'
EMAIL_HOST_PASSWORD = '*****'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
更新:
这段代码成功了
'There has been an inquiry for' + str(property) + 'Check it',
发送邮件功能中缺少一个
,
,希望对您有所帮助。请提供一个,以及整个错误消息。“属性查询”后缺少一个逗号。
当您想将str与布尔值连接时,您也应该将布尔值转换为str,就像“已对”+str(属性)进行查询一样+“Check it”
当我尝试将布尔值转换为str时,我得到一个“send\u mail()缺少1个必需的位置参数:”recipient\u list“错误