1

I'm trying to deploy django project to webfaction and stuck with the problem that the server does not see my templates folder

PROJECT_DIR = os.path.dirname((os.path.dirname((os.path.dirname(__file__)))))

    TEMPLATE_DIRS = (
    os.path.join(PROJECT_DIR,'templates'),
   )

python path in httpd.conf :

 python-path=/home/wadadaaa/webapps/promo_site/myproject:/home/wadadaaa/webapps/promo_site/lib/python2.7

And i have exception:

Exception Type: TemplateDoesNotExist
Exception Value: index.html 

Django tried loading these templates, in this order:
Using loader django.template.loaders.filesystem.Loader:
/home/wadadaaa/webapps/promo_site/templates/index.html (File does not exist)

any ideas how to fix it?

wadadaaa
  • 309
  • 1
  • 4
  • 21

1 Answers1

0

When deploying to WebFaction I add the project's parent directory to the python_path:

python-path=/home/wadadaaa/webapps/promo_site:/home/wadadaaa/webapps/promo_site/myproject:/home/wadadaaa/webapps/promo_site/lib/python2.7

If you're using Django 1.5.x, a common way I "map" directory paths like TEMPLATE_DIRS, STATIC_ROOT, etc, is to use a function to compute those. This is especially useful if you work on more than one machine, or in a group, where the path to these files is going to vary per-developer:

# settings.py
import os

def map_path(directory_name):
    return os.path.join(os.path.dirname(__file__),
        '../' + directory_name).replace('\\', '/')
...

TEMPLATE_DIRS = (
    map_path('templates'),
)

This is a convenient way to map your templates directory, given a project structure of:

my_app/
    my_app/
        __init__.py
        settings.py
        ...

    a_module/
        __init__.py
        models.py

    templates/
        layouts/
            base.html

        index.html
        ...
Brandon Taylor
  • 33,823
  • 15
  • 104
  • 144