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 <[email protected]>

>  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:
>
> 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?
>
>  --
> 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 [email protected].
> To post to this group, send email to [email protected].
> 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 [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/django-users.
For more options, visit https://groups.google.com/groups/opt_out.

Reply via email to