I am trying to create my own project with Django version 1.9.x, but I can't make the index page at /
to work.
This is my folder structure:
rxe/
urls.py
wsgi.py
settings.py
blog/
migrations/
static/
blog/
css/
js/
img/
templates/
blog/
index.html
admin.py
models.py
tests.py
urls.py
views.py
manage.py
rxe/urls.py
:
urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'$', include('blog.urls')),
]
blog/urls.py
:
from django.conf.urls import url
from . import views
urlpatterns = [
url(r'^$', views.IndexView.as_view(), name = 'index'),
]
blog/views.py
:
from django.http import HttpResponse, HttpResponseRedirect
from django.views.generic import TemplateView
class IndexView(TemplateView):
template_name = 'blog/index.html'
When accessing localhost:8000/
, the error:
TemplateDoesNotExist at /
blog/index.html
And right below it, in Template-loader postmortem:
django.template.loaders.app_directories.Loader: /usr/local/lib/python2.7/dist-packages/Django-1.9.4-py2.7.egg/django/contrib/admin/templates/blog/index.html (Source does not exist)
django.template.loaders.app_directories.Loader: /usr/local/lib/python2.7/dist-packages/Django-1.9.4-py2.7.egg/django/contrib/auth/templates/blog/index.html (Source does not exist)
It works if I return an HttpResponse('Hello')
, like in the tutorial, but this same tutorial does not have any view for /
path, and I want one there.
Edit
rxe/settings.py
, how it was created:
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
settings.py
file? - fermoga