Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I include a template that includes another template?
    primarykey
    data
    text
    <p>I have index.html, which loads project/p1.html, which loads project/p2.html. project/p1.html and project/p2.html each load fine on their own, so I know they work correctly. The problem is trying to load project/p1.html into index.html, which has the statement:</p> <pre><code>{% include 'project/p1.html' %} </code></pre> <p>project/p1.html has the statement:</p> <pre><code>{% include 'project/p2.html' %} </code></pre> <p>Loading index.html, I get the error: </p> <pre><code>VariableDoesNotExist at / Failed lookup for key [objects] in u"[{'params': {}}, {'csrf_token': &lt;django.utils.functional.__proxy__ object at 0x7fd3dc0e2410&gt;}, {'perms': &lt;django.contrib.auth.context_processors.PermWrapper object at 0x7fd3dc0e2210&gt;, 'user': &lt;django.utils.functional.SimpleLazyObject object at 0x7fd3dc10c790&gt;}, {},...... </code></pre> <p>If I delete "{% include 'project/p2.html' %}" from project/p1.html, index.html loads fine and the error message dissapears (but obviously I can't see my content).</p> <p>How do I resolve this?</p> <p>EDIT: Heres "project/p2.html":</p> <pre><code>&lt;table class="mytable"&gt; {% for object in objects %} &lt;tr class="my_row"&gt; &lt;td&gt;{{ object.name }}&lt;/td&gt; &lt;/tr&gt; {% endfor %} &lt;/table&gt; </code></pre> <p>Here's views.py:</p> <pre><code>from models import Mytable from django.shortcuts import render_to_response, RequestContext def my_request(request, template="project/p1.html", page_template="project/p2.html"): context = { 'objects': Mytable.objects.all().order_by('-date'), 'page_template': page_template, } if request.is_ajax(): template = page_template return render_to_response(template, context, context_instance=RequestContext(request)) </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload