Source

article / article / views.py

Diff from to

article/views.py

 from django.contrib.sessions.models import Session
 from django.views.decorators.csrf import csrf_exempt
 from django.views.generic.dates import ArchiveIndexView, MonthArchiveView, YearArchiveView
+from django.core.mail import send_mail
 
 from tagging.models import TaggedItem, Tag
 from mailsnake import MailSnake
 from article.models import Post, Recipe, Ingredient
 from article.models import RecipeIngredient, RecipePhotos, UserPhotos
 from community.models import UserProfile, Transaction
+from article.forms import ContactForm
 
 
 def main_index(request):
 
     else:
         return HttpResponse("Your request is not valid for MailChimp signup.")
+
+def contact(request):
+    if request.method == 'POST':
+        form = ContactForm(request.POST) 
+        if form.is_valid():
+            send_mail('Contact Form email from {0}'.format(request.POST['name']), request.POST['message'], request.POST['email'], ['lindsay@happyherbivore.com'], fail_silently=False)
+            success = True
+    else:
+        form = ContactForm()
+
+    return render_to_response('contact.html', locals(), context_instance=RequestContext(request))