Created
March 31, 2016 02:15
-
-
Save fandrefh/d92ce76d460506a52be479bf6b5ec875 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#contact.html | |
<!-- Contact form --> | |
<form method="POST" action="{% url 'contact:contact_us' %}" class="pi-contact-form"> | |
{% csrf_token %} | |
<div class="pi-error-container"></div> | |
<div class="pi-row pi-grid-small-margins"> | |
<div class="pi-col-sm-6"> | |
<div class="form-group pi-padding-bottom-10"> | |
<label for="id_name">Nome *</label> | |
{{ contact_form.name|attr:"placeholder:Seu nome aqui"|attr:"required"|add_class:"form-control form-control-name" }} | |
</div> | |
<div class="form-group pi-padding-bottom-10"> | |
<label for="id_email">Email *</label> | |
{{ contact_form.email|attr:"placeholder:Seu email aqui"|attr:"type:email"|attr:"required"|add_class:"form-control form-control-email" }} | |
</div> | |
</div> | |
<div class="pi-col-sm-6"> | |
<div class="form-group pi-padding-bottom-10"> | |
<label for="id_corp">Empresa</label> | |
{{ contact_form.corp|attr:"placeholder:Sua empresa aqui"|add_class:"form-control form-control-company-name" }} | |
</div> | |
<div class="form-group pi-padding-bottom-10"> | |
<label for="id_phone">Telefone *</label> | |
{{ contact_form.phone|attr:"placeholder:Seu telefone aqui"|attr:"required"|add_class:"form-control form-control-phone" }} | |
</div> | |
</div> | |
</div> | |
<div class="form-group pi-padding-bottom-10"> | |
<label for="id_message">Mensagem *</label> | |
{{ contact_form.message|attr:"placeholder:Deixe sua mensagem aqui"|attr:"required"|add_class:"form-control form-control-comments" }} | |
</div> | |
<p> | |
<button type="submit" class="btn pi-btn-base"> | |
Enviar Mensagem<i class="icon-paper-plane pi-icon-right"></i> | |
</button> | |
</p> | |
</form> | |
<!-- End contact form --> | |
#views.py | |
def contact_us(request): | |
if request.method == 'POST': | |
contact_form = ContactUsForm(request.POST or None) | |
if contact_form.is_valid(): | |
c = contact_form.save() | |
return HttpResponse("foi...") | |
else: | |
print(contact_form.errors) | |
else: | |
contact_form = ContactUsForm() | |
return render(request, 'contact/contact.html', {'contact_form': contact_form}) | |
#urls.py | |
from django.conf.urls import url | |
from . import views | |
urlpatterns = [ | |
url(r'^fale-conosco/$', views.contact_us, name='contact_us'), | |
] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment