亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

Django 如何分配從 HTML 按鈕發送電子郵件的功能

Django 如何分配從 HTML 按鈕發送電子郵件的功能

眼眸繁星 2024-01-03 15:03:17
我是 django 的新手,我想知道如何將函數“Initial_Report(request):”賦予 html 按鈕,以便每次單擊它都會執行給定的函數。查看代碼def home(request):return render(request, 'home.html')def Initial_Report(request):noc_emails = Employee.objects.exclude(Position__Position__contains='Customer').values_list('Email', flat=True)cs_emails = Employee.objects.filter(Position__Position__contains = 'Customer').values_list('Email', flat=True)noc_message = ('Initial Outage Report', 'This is a new outage report ,The information is in the document', '[email protected]', noc_emails)cs_message = ('Initial Outage Report', 'This is a new outage report ,The information is in the document', '[email protected]', cs_emails)send_mass_mail((noc_message,cs_message), fail_silently=False)return render(request,'InitialReport.html')網址urlpatterns = [path('', views.home, name='home.html'),path('admin/', admin.site.urls),path('Initial_Report', views.Initial_Report, name = 'Initial_Report' ),]首頁.html<button> Send Initial Report</button>
查看完整描述

1 回答

?
侃侃無極

TA貢獻2051條經驗 獲得超10個贊

sinceInitial_Report在觸發 /Initial_Report 時調用

path('Initial_Report', views.Initial_Report, name = 'Initial_Report' ),

您可以添加一個鏈接到路徑

<a href= "/Initial_Report"> Send Initial Report</a>


查看完整回答
反對 回復 2024-01-03
  • 1 回答
  • 0 關注
  • 157 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號