from django.shortcuts import HttpResponse, render
from .validate import create_validate_code
from io import BytesIO
from PIL import Image
from .forms import ContactForm
def test(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
your_name = form.cleaned_data['your_name']
your_email = form.cleaned_data['your_email']
your_country = form.cleaned_data['your_country']
your_Product = form.cleaned_data['your_Product']
your_comment = form.cleaned_data['your_comment']
code = form.cleaned_data['code']
if code == request.session['validate']:
recipients = ['justman880221@live.com']
content = your_comment + your_name + your_country
if your_Product:
content.append(your_Product)
from django.core.mail import send_mail
send_mail(your_name, content, your_email, recipients)
return HttpResponseRedirect('/thanks/')
else:
form = ContactForm()
return render(request, 'Samples/contact.html', {'form', form})
这一行引起的错误返回render(request,'Samples/联系人.html',{form',form})
我是新来的Django,能帮我找出哪个部分出了问题,以及如何解决这个问题?在
^{pr2}$This is my form.py
This is html page
<form action="/Samples/test/" method="post">
<p>
{% csrf_token %}
{{ form.as_p }}
</p>
<p class="form_p">
<strong class="captcha_box">
<span class="captcha_img"><img id="refresh_img" src="/Samples/validate/"/> </span>
<span onclick="myFunction()" title="Get a new challenge" class="captcha_reload ico" ></span>
</strong>
</p>
<p class="form_p">
<input class="btn" value="Seed Message" type="submit" />
</p>
</form>
{'form', form}
是集合文本,不是字典文本。在它应该是(
,
>;:
)因为它是字典,所以它应该是}
:
而不是{相关问题 更多 >
编程相关推荐