Hi,
I am trying to get an inclusion_tag to work in a template. crudapp_tags.py is,
from django import template
register = template.Library()
@register.inclusion_tag("forum.html")
def results(poll):
form = 'blah'
return {'form': form}
templates/forum.html
{% extends 'index.html' %}
{% load crudapp_tags %}
{% results poll %}
<p>aaa</p>
{% block homepage %}
<p>bbb</p> <!-- Only this displays -->
{% if form %}
<p>Form exists</p>
{% endif %}
{% for item in form %}
<p>This is {{ item }}</p>
{% endfor %}
<div>
<p>{% if user.is_authenticated %}Add a New Topic: <a href="{% url 'topic_form' %}"><span class="glyphicon glyphicon-plus"></span></a>{% endif %}</p>
</div>
<div>
<p>{{ totalposts.count }} posts, {{ totaltopics.count }} topics, {{ totalusers.count }} users, {{ totalviews.numviews}} views</p>
</div>
<div class="post">
{% if pModel %}
<div class="table-responsive">
<table class='table table-striped table-hover'>
<thead>
<tr>
<th>Topic</th>
<th>Topic Started By</th>
<th>Last Active</th>
<th class="table-cell-center">Views</th>
<th class="table-cell-center">Posts</th>
</tr>
</thead>
<tbody>
{% for item in pModel %}
<tr>
<td><a href="{% url 'thread' item.topic_id %}">{{ item.topic.topic }}</a></td>
<td><a href="{% url 'profile' item.topic.author_id %}">{{ item.topic.topicAuthor }}</a></td>
<td class="icon-nowrap">{{ item.pub_date|timesince:current_time}}</td>
<td class="table-cell-center">{{ item.topic.views }}</td>
<td class="table-cell-center">{{ item.freq }}</td>
</tr>
{% endfor %}
</tbody>
</table>
{% endif %}
</div>
</div>
{% endblock %}
The app crudapp is installed in crudProject/settings.py
The file setup looks like this,
Content of ‘form’ which id ‘blah’ should be displaying in 'forum.html. which extends 'index.html. But it isn’t.
Any help would be greatly appreciated.
Thanks,