第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

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

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

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

眼眸繁星 2024-01-03 15:03:17
我是 django 的新手,我想知道如何將函數(shù)“Initial_Report(request):”賦予 html 按鈕,以便每次單擊它都會執(zhí)行給定的函數(shù)。查看代碼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', 'from@example.com', noc_emails)cs_message = ('Initial Outage Report', 'This is a new outage report ,The information is in the document', 'from@example.com', cs_emails)send_mass_mail((noc_message,cs_message), fail_silently=False)return render(request,'InitialReport.html')網(wǎng)址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貢獻(xiàn)2051條經(jīng)驗(yàn) 獲得超10個贊

sinceInitial_Report在觸發(fā) /Initial_Report 時(shí)調(diào)用

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

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

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


查看完整回答
反對 回復(fù) 2024-01-03
  • 1 回答
  • 0 關(guān)注
  • 148 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號