Я новичок в 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')
URL
urlpatterns = [
path('', views.home, name='home.html'),
path('admin/', admin.site.urls),
path('Initial_Report', views.Initial_Report, name = 'Initial_Report' ),
]
Home. html
<button> Send Initial Report</button>