我是 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', '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')
网址
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>
侃侃无极
相关分类