【发布时间】:2018-07-31 21:00:35
【问题描述】:
我想创建一个应用程序,如果有人想申请为我的公司工作,我将在我的应用程序中创建一个条目,然后我会向他们发送一个唯一的 URL,该 URL 会指向我想要的表单页面要散列的 URL,但我不太确定如何执行此操作。以下是我的代码:
view.py:
def applicant_email_view(request):
form = ApplicantEmailForm(request.POST or None)
if form.is_valid():
inst = form.save(commit=False)
subject = 'Applicant Form'
text_content = 'Hola'
html_content = """
<h3 style="color: #0b9ac4><a>http://127.0.0.1:8080/hiring/application_form/</a></h3>
"""
to = [inst.applicant_email]
send_email(subject, text_content, html_content, to)
inst.save()
return render(request, 'hiring/applicant_email.html', {'form': form})
def application_form_view(request):
form = JobApplicationForm(request.POST or None, request.FILES or None)
if form.is_valid():
inst = form.save(commit=False)
inst.save()
context = {'form': form}
return render(request, 'hiring/application_form.html', context=context)
def send_email(subject, text_content, html_content, to):
from_email = 'test@testing.studio'
footer = """<h5>Do not reply to this email. This is automated email notification from LemonCORE.</h5>
</br>
"""
email_body = html_content + footer
msg = EmailMultiAlternatives(subject, text_content, from_email, to)
msg.attach_alternative(email_body, "text/html")
msg.send()
url.py:
url(r'^hiring/application_email/$', applicant_email_view, name='application_email_view'),
url(r'^hiring/application_form/$', application_form_view, name='application_form_view'),
【问题讨论】: