1
Fork 0

Added contact form to backend

This commit is contained in:
Jake Howard 2016-01-14 20:01:47 +00:00
parent f870056f04
commit 7db7182438
3 changed files with 20 additions and 3 deletions

View file

@ -1,3 +1,6 @@
from django import forms
class ContactForm(forms.Form): class ContactForm(forms.Form):
email = forms.CharField(label="Email Address", widget=forms.EmailInput(attrs={'placeholder': 'Email Address'})) email = forms.CharField(label="Email Address", widget=forms.EmailInput(attrs={'placeholder': 'Email Address'}))
name = forms.CharField(label="Full Name", widget=forms.TextInput(attrs={'placeholder': 'Full Name'})) name = forms.CharField(label="Full Name", widget=forms.TextInput(attrs={'placeholder': 'Full Name'}))

View file

@ -1,4 +1,4 @@
from django.views.generic import TemplateView from django.views.generic import TemplateView, FormView
class CustomTemplate(TemplateView): class CustomTemplate(TemplateView):
@ -11,3 +11,15 @@ class CustomTemplate(TemplateView):
context['body_class'] = self.body_class context['body_class'] = self.body_class
context['js_redirect'] = True context['js_redirect'] = True
return context return context
class CustomFormTemplate(FormView):
html_title = ""
body_class = ""
def get_context_data(self, **kwargs):
context = super().get_context_data(**kwargs)
context['html_title'] = self.html_title
context['body_class'] = self.body_class
context['js_redirect'] = True
return context

View file

@ -1,4 +1,5 @@
from project.common.views import CustomTemplate from project.common.views import CustomTemplate, CustomFormTemplate
from project.common.forms import ContactForm
class IndexView(CustomTemplate): class IndexView(CustomTemplate):
@ -29,9 +30,10 @@ class AboutWebsiteView(CustomTemplate):
html_title = "About website" html_title = "About website"
class AboutIndexView(CustomTemplate): class AboutIndexView(CustomFormTemplate):
template_name = 'about/index.html' template_name = 'about/index.html'
html_title = "About" html_title = "About"
form_class = ContactForm
class AboutMeView(CustomTemplate): class AboutMeView(CustomTemplate):