I tried to follow the tutorial to the point but I keep getting TemplateDoesNotExist at /. Then I tried to modify few things but still I keep getting the error. Right now the configuration is like this.
My project tree:
microblog/
├── manage.py
├── microblog
│ ├── __init__.py
│ ├── __init__.pyc
│ ├── settings
│ │ ├── base.py
│ │ ├── base.pyc
│ │ ├── __init__.py
│ │ ├── __init__.pyc
│ │ ├── local.py
│ │ └── local.pyc
│ ├── urls.py
│ ├── urls.pyc
│ ├── views.py
│ ├── wsgi.py
│ └── wsgi.pyc
├── requirements.txt
└── templates
├── 500.html
└── index.html
My settings/base.py which is essentially equivalent to settings.py
import os
...
PROJECT_ROOT = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
...
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader',
)
...
TEMPLATE_DIRS = (
os.path.join(PROJECT_ROOT, 'templates'),
)
My urls.py
from django.views.generic import TemplateView
...
urlpatterns = patterns('',
...
url(r'^$', TemplateView.as_view(template_name="index.html")),
...
)
and I added a views.py just in case
from django.views.generic import TemplateView
class HomepageView(TemplateView):
template_name = "index.html"
Always I get the error message "TemplateDoesNotExist at /"
Django tried loading these templates, in this order:
- Using loader
django.template.loaders.filesystem.Loader
:/home/voger/PycharmProjects/microblog/microblog/templates/index.html
(File does not exist)
- Using loader
django.template.loaders.app_directories.Loader
:/home/voger/blog-venv/lib/python2.7/site-packages/django/contrib/auth/templates/index.html
(File does not exist)/home/voger/blog-venv/lib/python2.7/site-packages/django/contrib/admin/templates/index.html
(File does not exist)
- Using loader
django.template.loaders.eggs.Loader
:
If it would try the first two lines the file is sitting right there so what is wrong with it?
No comments:
Post a Comment