First time here? Check out the FAQ!

Template not found

Hi I have added a app to askbot the way I have done is I have created my app inside askbot folder: So the structure looks like follows:

|__ Utils
|__ upfiles
|__ ... 
|__ experiments
                |__ *.html

but the problem is I am getting template not found: The error is bit confusing to understand:

My exact error is as follows:

TemplateNotFound at /questions/
Request Method: GET
Request URL:    http://localhost:8001/questions/
Django Version: 1.4.10
Exception Type: TemplateNotFound
Exception Value:    
Exception Location: /Users/mac/code/vEnv/myanswers/askbot/templates/base.html in top-level template code, line 3
Python Executable:  /Users/mac/code/vEnv/myanswers/bin/python
Python Version: 2.7.5
Python Path:

What might i be doing wrong here..?

SocialQA's avatar
asked 2013-12-08 14:19:31 -0500
edit flag offensive 0 remove flag close merge delete


How are you rendering the template in the views?

Evgeny's avatar Evgeny (2013-12-09 12:43:41 -0500) edit

for an example `def experiment_details(request, experiment_name, template_name="experiments/experiment_details.html"):`

SocialQA's avatar SocialQA (2013-12-09 13:21:41 -0500) edit

Try the `TEMPLATE_DIRS` setting to add the directory.

Evgeny's avatar Evgeny (2013-12-09 13:26:24 -0500) edit

by default its commented so should I uncomment and add the dir of the new project to that..?

SocialQA's avatar SocialQA (2013-12-09 14:06:54 -0500) edit

Look into the Django documentation for that info.

Evgeny's avatar Evgeny (2013-12-09 14:21:39 -0500) edit
add a comment see more comments

1 Answer


Try adding your template directory to setting TEMPLATE_DIRS.

Also, if you put your templates inside the askbot/templates it should work if you do something like this:

from django.shortcuts import render
return render(request, 'experiments/template.html', template_data)
Evgeny's avatar
answered 2013-12-09 12:47:40 -0500
edit flag offensive 0 remove flag delete link


In the current setting TEMPLATE_DIR is commented and there is a note saying read: based on that looks like if I turn on TEMPLATE_DIR entire askbot TEMPLATES will change because it will try to read the tempaltes from that location..? But all I want is templates related to the new app to read from that location.

SocialQA's avatar SocialQA (2013-12-09 14:10:12 -0500) edit

I want to add following to base.html so this script would be available in all the templates: Is it ok to add such things to base.html. <script language="javascript" src="{% get_static_prefix %}javascripts/experiments.js" type="text/javascript"> {% include "experiments/include/experiment_enrollment.html" %}

SocialQA's avatar SocialQA (2013-12-09 14:26:14 -0500) edit

Sure, why not.

Evgeny's avatar Evgeny (2013-12-09 14:26:55 -0500) edit

can you confirm on one thing: If I put the template path of the application that I have added inside askbot folder to TEMPLATE_DIR, entire askbot will use that location instead of askbot/templates?

SocialQA's avatar SocialQA (2013-12-09 14:31:08 -0500) edit

if the experiments is inside askbot should I be adding {% include "askbot/experiments/include/experiment_enrollment.html" %} or experiments/include/experiment_enrollment.html

SocialQA's avatar SocialQA (2013-12-09 14:40:35 -0500) edit
add a comment see more comments