Hello,
While I was following the chapter 7 (Form processing) of the django
book, I got the following error:
Traceback (most recent call last):
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/core/handlers/base.py" in get_response
77. response = callback(request, *callback_args, **callback_kwargs)
File "/Users/yjlee/Documents/Worx/Django/DjangoWorx/mysite2/../mysite2/
books/views.py" in contact
30. message, sender, ['
admini...@example.com'])
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/core/mail.py" in send_mail
49. return send_mass_mail([[subject, message, from_email,
recipient_list]], fail_silently, auth_user, auth_password)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
site-packages/django/core/mail.py" in send_mass_mail
66. server = smtplib.SMTP(settings.EMAIL_HOST, settings.EMAIL_PORT)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
smtplib.py" in __init__
244. (code, msg) = self.connect(host, port)
File "/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/
smtplib.py" in connect
310. raise socket.error, msg
error at /contact/
(49, "Can't assign requested address")
It seems that this error was coming from HttpResponseRedirect() of the
contact view method, but I did not figure what went wrong. This is my
"contact" view method:
def contact(request):
if request.method == 'POST':
form = ContactForm(request.POST)
if form.is_valid():
topic = form.clean_data['topic']
message = form.clean_data['message']
sender = form.clean_data.get('sender', '
nor...@example.com')
send_mail('Feedback from your site, topic: %s' % topic,
message, sender, ['
admini...@example.com'])
return HttpResponseRedirect('/contact/thanks/')
else:
form = ContactForm()
return render_to_response('books/contact.html', {'form': form})
One odd thing is that I got the same error (cannot assign requested
address) even if I tried to redirect HttpResponse to "http://
www.google.com".
Can anyone explain how to resolve this problem?
Thanks in advance,
YJ