Reputation: 787
I'm using django 1.8 as that was a requirement.
With this app, I'm building a bookstore project. Currently the only app created is 'store'. Now, I am trying to create a form that allows for account registration. This form is to send an email to the email that the user enters. The email has a link with a url that adds the account activation code.
This works up until the email is to be sent (when the user adds their information and clicks submit. That is where the error occurs.
When I am pressing submit on the form, I'm seeing the following error. I don't really know what is going on here. I have added the django.contrib.auth to the installed apps, made sure that all migrations have taken place, refactored the urls as much as I can think of and still no love.
If anyone has any advice, please let me know. If possible please explain it to me like I'm five as this is my first djano project and I'm still treading water here. If you can relate it to flask, that might also help.
Big thanks in advance.
error at /accounts/register/
[Errno 65] No route to host
Request Method: POST
Request URL: http://localhost:8000/accounts/register/
Django Version: 1.8
Exception Type: error
Exception Value:
[Errno 65] No route to host
Exception Location: /Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/socket.py in create_connection, line 571
Python Executable: /Users/MNickey/PycharmProjects/django_bookstore/venv/bin/python
Python Version: 2.7.9
Python Path:
['/Users/MNickey/PycharmProjects/django_bookstore/Development/django_bookstore', '/Users/MNickey/PycharmProjects/django_bookstore/venv/lib/python2.7/site-packages/setuptools-0.6c11-py2.7.egg',
'/Users/MNickey/PycharmProjects/django_bookstore/venv/lib/python2.7/site-packages/pip-1.3.1-py2.7.egg',
'/Users/MNickey/PycharmProjects/django_bookstore/venv/lib/python27.zip',
'/Users/MNickey/PycharmProjects/django_bookstore/venv/lib/python2.7',
'/Users/MNickey/PycharmProjects/django_bookstore/venv/lib/python2.7/plat-darwin',
'/Users/MNickey/PycharmProjects/django_bookstore/venv/lib/python2.7/plat-mac',
'/Users/MNickey/PycharmProjects/django_bookstore/venv/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/MNickey/PycharmProjects/django_bookstore/venv/lib/python2.7/lib-tk',
'/Users/MNickey/PycharmProjects/django_bookstore/venv/lib/python2.7/lib-old',
'/Users/MNickey/PycharmProjects/django_bookstore/venv/lib/python2.7/lib-dynload',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
'/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
'/Users/MNickey/PycharmProjects/django_bookstore/venv/lib/python2.7/site-packages']
Server time: Tue, 29 Dec 2015 02:10:12 +0000
Views.py:
from django.shortcuts import render
from .models import Book
def index(request):
return render(request, 'template.html')
def store(request):
count = Book.objects.all().count()
context = {
'count': count,
}
return render(request, 'store.html', context)
Urls.py:
from django.conf.urls import include, url
from django.contrib import admin
urlpatterns = [
# Examples:
# url(r'^$', 'django_bookstore.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
# url(r'^$', 'store.views.index', name='index'),
url(r'^store/', include('store.urls'), name='store'),
url(r'^accounts/', include('registration.backends.default.urls')),
url(r'^admin/', include(admin.site.urls)),
]
Store/urls.py:
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.store, name='index'),
]
Settings.py (partial):
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites.requests',
'registration',
'store',
)
# Registration
ACCOUNT_ACTIVATION_DAYS = 7
REGISTRATION_AUTO_LOGIN = True
LOGIN_REDIRECT_URL = '/store/'
# Email Settings
EMAIL_BACKEND = "django.core.mail.backends.smtp.EmailBackend"
EMAIL_HOST = "smtp.gmail.com"
EMAIL_HOST_USER = "[email protected]"
EMAIL_HOST_PASSWORD = "password removed"
EMAIL_POST = 587
EMAIL_USE_TLS = True
DEFAULT_FROM_EMAIL = "[email protected]"
Upvotes: 1
Views: 7064
Reputation: 787
Change EMAIL_POST = 587 in your settings.py to be EMAIL_PORT = 587. Making this change resolved the issue. So yes it was network connectivity because the network was doing what it was supposed to do.
Upvotes: 1
Reputation: 1797
The literal interpretation of error 65 (EHOSTUNREACH) is that there is no network route to the host. First question: what's the host? Your question says that it's trying to send mail at the time of the error. So it's probably your SMTP server host. Where is that defined? Can you log it?
EDIT: I misinterpreted the error message a bit, sorry :/
Upvotes: 0