Well, this is embarrassing but the file wasn't in the path after all. A simple ls would reveal that. It was one level higher than that.
So I moved the directory templates inside the microblog and now it works.
On 09/02/2013 04:07 PM, Sandro Dutra wrote:
So I moved the directory templates inside the microblog and now it works.
On 09/02/2013 04:07 PM, Sandro Dutra wrote:
Django cannot load the template, probably the path is wrong, try to put this in your settings:
TEMPLATE_DIRS = (os.path.join(os.path.dirname(__file__), '..', 'templates').replace('\\','/'),)
About the views, I think you don't need to code it if in your urls.py you already used the TemplateView.as_view--
2013/9/2 vogernewsletters <vogernewsletters@yahoo.gr>
Hi I am new to both Python and Django. I am studying various tutorials and now I am following the tutorial from http://gettingstartedwithdjango.com where the author walks through the creation of a simple microblog.
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:My settings/base.py which is essentially equivalent to settings.py
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
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.pyurlpatterns = patterns('',
from django.views.generic import TemplateView
...
...
...
url(r'^$', TemplateView.as_view(template_name="index.html")),
)
and I added a views.py just in case
from django.views.generic import TemplateViewAlways I get the error message "TemplateDoesNotExist at /"
class HomepageView(TemplateView):
template_name = "index.html"
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?
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.
No comments:
Post a Comment