[Answer]-I can't figure out how to refer to my template from a Django view

1👍

The TEMPLATE_DIRS in your settings.py should point to the template folder.

Should be something like this:

TEMPLATE_DIRS = (
    '../home/templates'
)

That should work.

Note: There you’re using relative paths which is not recommended. You should have something like this in your settings.py:

import os
settings_dir = os.path.dirname(__file__)
PROJECT_ROOT = os.path.abspath(os.path.dirname(settings_dir))

...

TEMPLATE_DIRS = (
    os.path.join(PROJECT_ROOT, '../home/templates/'),
)

Also, you’re calling render_to_response without passing it a RequestContext. With this, your templates will lack of some variables important for your project like user. It’s better to call it this way:

return render_to_response(
    "home/main.html",
    context_instance=RequestContext(
        request,
        {'name':'maxwell'}
    )
)

Leave a comment