Hi, I am total newbie when it comes to both Python and Django. I followed few tutorials but still can't get things to click at all. Now I am trying to follow the tutorial from http://gettingstartedwithdjango.com. I use PyCharm as an ide and generated from there the starting project. My problem is that no matter what I do I always get an error
-- "TemplateDoesNotExist at /"
I began following the tutorial to the point but trying to overcome the problem I did a few changes. Right now I have a folder structure like this:
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
In my base.py which is equivalent to settings.py I have
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'),
)
In my urls.py
from django.views.generic import TemplateView
...
url(r'^$', TemplateView.as_view(template_name="index.html")),
and my views.py:
from django.views.generic import TemplateView
class HomepageView(TemplateView):
template_name = "index.html"
But still when I run the runserver from PyCharm or from command line I still get
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) <---- This one I am sure it does
- 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
:
Can you please help me figure what is wrong?
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