DJANTO之FORM

文档很仔细,但熟悉要慢慢来~~

from django.shortcuts import render
from contact.forms import ContactForm
from django.http import HttpResponseRedirect
from django.core.mail import send_mail

def contactview(request):
    if request.method == 'POST':
        form = ContactForm(request.POST)
        if form.is_valid():
            cd = form.cleaned_data
            send_mail(
                cd['subject'],
                cd['message'],
                cd.get('email','noreply@examlple.com'),
                ['siteowner@example.com'],
                )
            return HttpResponseRedirect('/contact/thanks/')
    else:
        form = ContactForm(
            initial={'subject':'I love this site'}
            )
    return render(request, 'contact_form.html', {'form':form})

DJANTO之FORMDJANTO之FORM

上一篇:php打包文件为ZIP包后下载到本地


下一篇:springMVC中ajax的使用