django TemplateNotFound error

I have a template paste_form.html, but it doesn't get rendered.

from django.template.loader import get_template
get_template('paste_form.html')

<django.template.base.Template object at 0x1057c9710>

So it seems to exist somewhere. But according to the template loader post-mortem:

Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
Using loader django.template.loaders.app_directories.Loader:
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/auth/templates/pastebin/paste_form.html (File does not exist)
/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django/contrib/admin/templates/pastebin/paste_form.html (File does not exist)
/Users/cole/PycharmProjects/djenproject/pastebin/templates/pastebin/paste_form.html (File does not exist)

My template dir is: '/Users/cole/PycharmProjects/djenproject/pastebin/templates'

Whether this dir is commented out or not, I still get TemplateNotFound errors.

Trying to figure out something:

ROOTDIR = os.path.abspath(os.path.dirname(__file__))
ROOTDIR

'/Applications/PyCharm.app/helpers/pydev'

This kinda suprised me, but I'm nooby enough that surprise my actually indicate confusion.

How do I solve this problem?

Thanks, Cole
5 comments
Comment actions Permalink
Please make sure that the "Working directory" setting in your Django server run configuration is set to your project root directory.
0
Comment actions Permalink
I check under the Django Support tab of the settings, and it's set to:

/Users/cole/PycharmProjects/djenproject

This dir is the project root directory. I'm not sure where the Django server run configuration is though.
0
Comment actions Permalink
How exactly do you run your project from PyCharm?
0
Comment actions Permalink
I found the working directory in the django server. It was blank and I changed it. The problem remains.

I run the project by using PyCharm to run the following task: manage.py runserver. The admin page works fine so runserver handles that particular piece just fine.

I have changed very little from the install settings, adding only a path to django:

file:///Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/django (added by user)
0
Comment actions Permalink
I tried something else simple. I moved that admin base_site.html template to my templates folder. Made some changes. Nothing showed up in the admin page which django does find and serve.

I cannot seem to get PyCharm/Django to see my templates folder even though the template loader sees some object which corresponds to a template file.

Any suggestions
0

Please sign in to leave a comment.