Ok thanks, i'll have a look at the setup then.
On 10 Aug, 20:29, Daniel Roseman <dan...@roseman.org.uk> wrote:
> On Aug 10, 8:23 pm, When ideas fail <andrewkenyon...@gmail.com> wrote:
>
>
>
> > Hi, i've created a contact fom based on the one in the docs but i
> > don't know what to put as the action in the form element as part of
> > template. I've got this template:
>
> > <form action="contact_me" method="POST">
> > {{ form.as_p }}
> > <input type="submit" value="Submit" />
> > </form>
>
> > but presuambly the data is being handled by the view. I'd appreciate
> > any help, i tried it without an action and i got a 'Exception Value:
> > (10061, 'Connection refused') ' error.
>
> > Could someone please help?
>
> > Thanks
>
> > I've included a copy of the view below
> > ---------------------------------------------------------------------------
> > ---------------------------------------------------------------------
>
> > def contact_me(request):
> > if request.method == 'POST':
> > form = ContactForm(request.POST)
> > if form.is_valid():
> > subject = form.cleaned_data['subject']
> > message = form.cleaned_data['message']
> > sender = form.cleaned_data['sender']
> > cc_myself = form.cleaned_data['cc_myself']
>
> > recipients = ['andrewkenyon...@gmail.com']
> > if cc_myself:
> > recipients.append(sender)
>
> > from django.core.mail import send_mail
> > send_mail(subject, message, sender, recipients)
> > return HttpResponseRedirect('/thanks/')
>
> > else:
> > form = ContactForm()
>
> > return render_to_response('blogSite/contact_me.html', {'form':
> > form, })
>
> An empty string, or alternatively "." , is the correct thing to put.
> Action is misleadingly named - it's actually just a URL. So this means
> that the URL to POST to is the same one that originally rendered the
> view.
>
> Your form is acting correctly - the 'connection refused' error is
> presumably coming from the send_mail function inside your view,
> perhaps you haven't got the mail settings correct.
> --
> DR.
--~--~---------~--~----~------------~-------~--~----~
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+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---