I have managed to get examples showing on all pages for queryset section.
For example with my http://127.0.0.1:8000/testing/queryset_filter
page it displays like this
I use more than one object along with its variable within context to get values like this.
I have first 2 examples on this page shown in views.py
below
def queryset_filter(request):
mydata_filter = Member.objects.filter(firstname='Emil').values()
mydata_filterand = Member.objects.filter(lastname='Refsnes', id=2).values()
template = loader.get_template('testing/queryset_filter.html')
context = {
# Queryset straight filter method
'mymembers_filter': mydata_filter,
# Queryset filter and method
mymembers_filterand': mydata_filterand,
}
return HttpResponse(template.render(context, request))
In html queryset_fliter template, I have used code like this to display a filter example
<h4>QuerySet Filter Method Example</h4>
<p>Display only records where firstname is 'Emil' :</p>
<p>Queryset object :</p>
{{ mymembers_filter }}
<p>Loop through items :</p>
<table border='1'>
<tr>
<th>ID</th>
<th>Firstname</th>
<th>Lastname</th>
</tr>
{% for x in mymembers_filter %}
<tr>
<td>{{ x.id }}</td>
<td>{{ x.firstname }}</td>
<td>{{ x.lastname }}</td>
</tr>
{% endfor %}
</table>
So doing it this way worked and you can also use return render in views.py like this
return render(request, 'testing/queryset_filter.html', context)
So I am happy that this is now working.
I would now like to discuss with you how I can get other more complicated examples displaying on other pages, but on my Django Code Result not Displaying with include post.
Thanks
Robert