'Error at /contact/ -- [Errno 111] Connection refused (in the djangobook , chapter 7: Forms)
I get this error while I was learning Django from examples in djangobook (chapter 7 - Forms).
Full error:
error at /contact/
[Errno 111] Connection refused
Request Method: POST
Request URL: http://localhost:8000/contact/
Django Version: 1.8.4
Exception Type: error
Exception Value:
[Errno 111] Connection refused
Exception Location: /usr/lib/python2.7/socket.py in create_connection, line 571
Python Executable: /usr/bin/python
Python Version: 2.7.6
Here is the code:
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['message'],
cd.get('email', '[email protected]'),
['[email protected]'],
)
return HttpResponseRedirect('/contact/thanks/')
else:
form = ContactForm()
return render(request, 'contact_form.html', {'form': form})
Please resolve this error. Thanks.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
