Last active
August 29, 2015 13:58
-
-
Save ianseyer/9938887 to your computer and use it in GitHub Desktop.
This file contains 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
{% extends 'base.html' %} | |
{% block title %}Contact{% endblock %} | |
{% load crispy_forms_tags %} | |
{% block content %} | |
<div class='row contact'> | |
<div class='col-md-4'></div> | |
<div class='col-md-4'> | |
{% crispy_form %} | |
</div> | |
<div class='col-md-4'></div> | |
</div> | |
{% endblock %} |
This file contains 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
class Contact(forms.Form): | |
name = forms.CharField(max_length = 1000) | |
email = forms.EmailField(max_length = 1000) | |
message = forms.CharField() | |
captcha = CaptchaField() | |
def __init__(self, *args, **kwargs): | |
super(Contact, self).__init__(*args, **kwargs) | |
self.helper = FormHelper() | |
self.helper.form_class = 'contactForm' | |
self.helper.form_method = 'POST' | |
self.helper.form_id = 'contactForm' | |
self.helper.layout = Layout( | |
Fieldset( | |
'Contact', | |
Field('name'), | |
Field('email'), | |
Field('message'), | |
Field('captcha')), | |
ButtonHolder( | |
Submit('contact', 'Contact', css_class='submit'))) | |
def clean(self): | |
cleaned_data = self.cleaned_data | |
return cleaned_data |
This file contains 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 the owner/manager | |
def contact(request): | |
if request.method == 'POST': | |
form = Contact(request.POST) | |
if form.is_valid(): | |
send_mail('Someone contacted you via HomeOpCost', form.cleaned_data['message'], form.cleaned_data['email'], | |
['ian.seyer@gmail.com'], fail_silently=False) | |
else: | |
return render(request, 'contact.html', {'status':'Something went wrong.', 'form':form}) | |
else: | |
form = Contact() | |
return render(request, 'contact.html', {'form': form}) | |
This file contains 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
TemplateSyntaxError at /contact | |
Invalid block tag: 'crispy_form', expected 'endblock' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment