Creating a simple contact form
Hey guys,
I have a webfaction account, and I was trying to get a contact form
working for my website. The problem is that I can't seem to get it to
work. Can someone walk me through this? I couldn't figure it out from
the djangobook tutorial. I think something is wrong with my settings
and stuff. Here are my files:
forms.py:
from django import forms
class ContactForm(forms.Form):
email = forms.EmailField()
name = forms.CharField()
subject = forms.CharField()
message = forms.CharField(widget=forms.widgets.Textarea())
views.py:
def contact(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
cd = form.cleaned_data
send_mail(
cd['subject'] + " - " + cd['name'],
cd['message'],
cd.get('email', 'noreply@oneadmissions.com'),
['info@oneadmissions.com'],
)
return HttpResponseRedirect('/contact/thanks/')
else:
form = ContactForm()
return render_to_response('/home/oneadmin/webapps/oneadmin/
oneadmin/templates/oneadmissions/contact.html', {'form': form},
context_instance=RequestContext(request))
def thanks(request):
return render_to_response('/home/oneadmin/webapps/oneadmin/
oneadmin/templates/oneadmissions/random.html', {'phrase': "Thank you!
We will get back to you shortly"},
context_instance=RequestContext(request))
settings.py:
EMAIL_HOST = 'smtp.webfaction.com'
EMAIL_HOST_USER = 'info@oneadmissions.com' #the email account that
receives the email
EMAIL_HOST_PASSWORD = 'PASSWORD'
EMAIL_USE_TLS = True
*****I've tried adding an EMAIL_PORT, DEFAULT_FROM_EMAIL, and
SERVER_EMAIL variables, didn't do anything.
urls.py:
urlpatterns = patterns('',
(r'^contact/$', views.contact),
(r'^contact/thanks/$', views.thanks),
)
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
0 Comments:
Post a Comment
Subscribe to Post Comments [Atom]
<< Home