Ask Your Question
0

Template not found

asked 2013-12-08 14:19:31 -0600

SocialQA gravatar image

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:

askbot
|__Templates
|__Views
|__ Utils
|__ upfiles
|__ ... 
|__ experiments
      |__ __init__.py
      |__...
      |__templates
           |__experiments
                |__ *.html
                |__Include
                     |_experiment_enrollment.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/
askbot/experiments/templates/experiments/include/experiment_enrollment.html
Request Method: GET
Request URL:    http://localhost:8001/questions/
Django Version: 1.4.10
Exception Type: TemplateNotFound
Exception Value:    
askbot/experiments/templates/experiments/include/experiment_enrollment.html
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..?

edit retag flag offensive close merge delete

Comments

How are you rendering the template in the views?

Evgeny gravatar imageEvgeny ( 2013-12-09 12:43:41 -0600 )edit

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

SocialQA gravatar imageSocialQA ( 2013-12-09 13:21:41 -0600 )edit

Try the `TEMPLATE_DIRS` setting to add the directory.

Evgeny gravatar imageEvgeny ( 2013-12-09 13:26:24 -0600 )edit

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

SocialQA gravatar imageSocialQA ( 2013-12-09 14:06:54 -0600 )edit

Look into the Django documentation for that info.

Evgeny gravatar imageEvgeny ( 2013-12-09 14:21:39 -0600 )edit

1 Answer

Sort by ยป oldest newest most voted
1

answered 2013-12-09 12:47:40 -0600

Evgeny gravatar image

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)
edit flag offensive delete link more

Comments

In the current setting TEMPLATE_DIR is commented and there is a note saying read: http://askbot.org/en/question/2669/jinja-includes-and-extends-path-issue/ 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 gravatar imageSocialQA ( 2013-12-09 14:10:12 -0600 )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 gravatar imageSocialQA ( 2013-12-09 14:26:14 -0600 )edit
1

Sure, why not.

Evgeny gravatar imageEvgeny ( 2013-12-09 14:26:55 -0600 )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 gravatar imageSocialQA ( 2013-12-09 14:31:08 -0600 )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 gravatar imageSocialQA ( 2013-12-09 14:40:35 -0600 )edit

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 2013-12-08 14:19:31 -0600

Seen: 77 times

Last updated: Dec 09 '13