PythonAnywhere Forums

TemplateDoesNotExist at / -- Any Advice?

I have this error below.

/home/marroble/my-first-blog/myvenv/lib/python3.6/site-packages/django/template/loader.py in get_template, line 25

It also states this, and when I follow it there is no file there. But why is it checking it there?

Django tried loading these templates, in this order:

Using engine django: django.template.loaders.app_directories.Loader: /home/marroble/my-first-blog/myvenv/lib/python3.6/site-packages/django/contrib/admin/templates/blog/post_list.html (Source does not exist)

django.template.loaders.app_directories.Loader: /home/marroble/my-first-blog/myvenv/lib/python3.6/site-packages/django/contrib/auth/templates/blog/post_list.html (Source does not exist)

The HTML file is here and confirmed.

/home/marroble/my-first-blog/blog/Templates/blog

And this also works in my local machine and everything checks out. After pusing through github then paython anywhere i get the error code above.

Anyone knows what is going wrong here?

what is your templates path configuration in settings.py?

[edited by admin: formatting]

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',
            ],
        },
    },
]

Thank you for taking the time Conrad to help me out

don't you need to add /path/to/your/project/templates to DIRS?

I was following tutorial, my first project.

So, add the 'DIRS'[where I have the templates]?

Also, why did it work in the local machine and not on pythonanywhere?

Apologize for my ignorance as I only have the knowledge for following tutorial and learning python at the same time.

In addition, the tutorial had me do views.py and bogs/urls.py adjustments to point out. Which I think what makes the internal, local machine work.

from django.shortcuts import render

Create your views here.

def post_list(request): return render(request, 'blog/post_list.html', {})

Then, I uploaded to github and then here and I had that error ever since I rechecked my local machine, run the server on the shell and everything seems to work fine.

are you following the djangogirls tutorial? if so I think you've definitely gone wrong somewhere... it may be worth starting again, afresh, from the very beginning?

Harry, Yes. I am following that tutorial.

I am exactly at the creation of html template file directory. I got the same exact error per tutorial in local machine and after creating the html file and running the local server, everything is perfect.

Then github and then here PA and theirs works and mine does not. I will start over if that is last option, but to work in local machine and not here seems strange.

well, debugging it from this point is probably going to be harder work, but it's not impossible. first question: are you sure you've committed all the files you need on your own PC to your git repository, and pushed them to github, and pulled them down to pythonanywhere?

Yes, 100%.

To take your advise, how can I completely delete file fr oom python anywhere including the swgi file and use the bash to redo it?

you can delete a file from the file editor tab by navigating to the folder and hitting the delete button. Or you can use basah to delete it by using the rm command.

I have done it again, from step one of deployment to completion- after completely deleted all the files. Here is my result. I have opened all of the error codes. But the only error code matters is the 25, last error code. Hopefully, this maybe enough information?

Request Method: GET Request URL: http://marroble.pythonanywhere.com/ Django Version: 1.11.6 Exception Type: TemplateDoesNotExist Exception Value:
blog/post_list.html Exception Location: /home/marroble/my-first-blog/myvenv/lib/python3.6/site-packages/django/template/loader.py in get_template, line 25 Python Executable: /usr/local/bin/uwsgi Python Version: 3.6.0 Python Path:
['/var/www', '.', '', '/var/www', '/home/marroble/my-first-blog/myvenv/lib/python36.zip', '/home/marroble/my-first-blog/myvenv/lib/python3.6', '/home/marroble/my-first-blog/myvenv/lib/python3.6/lib-dynload', '/usr/lib/python3.6', '/home/marroble/my-first-blog/myvenv/lib/python3.6/site-packages', '/home/marroble/my-first-blog'] Server time: Thu, 12 Oct 2017 18:40:45 -0400

Traceback Switch to copy-and-paste view

/home/marroble/my-first-blog/myvenv/lib/python3.6/site-packages/django/core/handlers/exception.py in inner response = get_response(request) ... ▼ Local vars Variable Value exc TemplateDoesNotExist('blog/post_list.html',) get_response
<bound method BaseHandler._get_response of <django.core.handlers.wsgi.WSGIHandler object at 0x7f9c3fbf9898>> request <WSGIRequest: GET '/'> /home/marroble/my-first-blog/myvenv/lib/python3.6/site-packages/django/core/handlers/base.py in _get_response response = self.process_exception_by_middleware(e, request) ... ▼ Local vars Variable Value callback
<function post_list at 0x7f9c32d207b8> callback_args
() callback_kwargs {} middleware_method
<bound method CsrfViewMiddleware.process_view of <django.middleware.csrf.CsrfViewMiddleware object at 0x7f9c32e5f0b8>> request <WSGIRequest: GET '/'> resolver
<RegexURLResolver 'mysite.urls' (None:None) ^/> resolver_match
ResolverMatch(func=blog.views.post_list, args=(), kwargs={}, url_name=post_list, app_names=[], namespaces=[]) response
None self
<django.core.handlers.wsgi.WSGIHandler object at 0x7f9c3fbf9898> wrapped_callback
<function post_list at 0x7f9c32d207b8> /home/marroble/my-first-blog/myvenv/lib/python3.6/site-packages/django/core/handlers/base.py in _get_response response = wrapped_callback(request, callback_args, *callback_kwargs) ... ▼ Local vars Variable Value callback
<function post_list at 0x7f9c32d207b8> callback_args
() callback_kwargs {} middleware_method
<bound method CsrfViewMiddleware.process_view of <django.middleware.csrf.CsrfViewMiddleware object at 0x7f9c32e5f0b8>> request <WSGIRequest: GET '/'> resolver
<RegexURLResolver 'mysite.urls' (None:None) ^/> resolver_match
ResolverMatch(func=blog.views.post_list, args=(), kwargs={}, url_name=post_list, app_names=[], namespaces=[]) response
None self
<django.core.handlers.wsgi.WSGIHandler object at 0x7f9c3fbf9898> wrapped_callback
<function post_list at 0x7f9c32d207b8> /home/marroble/my-first-blog/blog/views.py in post_list return render(request, 'blog/post_list.html', {}) ... ▼ Local vars Variable Value request <WSGIRequest: GET '/'> /home/marroble/my-first-blog/myvenv/lib/python3.6/site-packages/django/shortcuts.py in render content = loader.render_to_string(template_name, context, request, using=using) ... ▼ Local vars Variable Value content_type
None context {} request <WSGIRequest: GET '/'> status
None template_name
'blog/post_list.html' using
None /home/marroble/my-first-blog/myvenv/lib/python3.6/site-packages/django/template/loader.py in render_to_string template = get_template(template_name, using=using) ... ▼ Local vars Variable Value context {} request <WSGIRequest: GET '/'> template_name
'blog/post_list.html' using
None /home/marroble/my-first-blog/myvenv/lib/python3.6/site-packages/django/template/loader.py in get_template raise TemplateDoesNotExist(template_name, chain=chain) ... ▼ Local vars Variable Value chain
[TemplateDoesNotExist('blog/post_list.html',)] engine
<django.template.backends.django.DjangoTemplates object at 0x7f9c334d6eb8> engines [<django.template.backends.django.DjangoTemplates object at 0x7f9c334d6eb8>] template_name
'blog/post_list.html' using
None

can i have permission to look at your files? (we can do it via our admin ui but we always ask first...)

Absolutely. Yes. What permission you need?

Took a look at your files. I see a folder called Templates with upper case T. Is the error just not finding the correct folder?

Ok. Thanks. I will do it again and reupload it. See what happens. Thank you.