예제 #1
0
def create(request):
    print request.POST
    print request.POST['name']
    print request.POST['breed']
    contacts = Contacts(name=request.POST['name'], breed=request.POST['breed'])
    contacts.save()
    return redirect('/')
예제 #2
0
def contact():
    form = ContactForm(request.form)
    if request.method == 'POST' and form.validate():
        name = form.data['name']
        email = form.data['email']
        message = form.data['message']
        contact = Contacts(name=name, email=email, comment=message)
        contact.save()
        send_email(name, email, message)
        time.sleep(5)
        return redirect('/')

    context = {'form': form}
    content = render_template('contact.html', **context)
    return content