[Fixed]-Python/ Django- How to change what information is displayed in a template?

1👍

{{block.super}} means block content of parent template.
Because parent template in your case is “pdf2_base.html” I suppose you can find required column in “pdf2_base.html” template.

Update
If you need to vary which block to show you can add context variable ‘post_deposit’:

if request.GET.get('stage') == 'pd':
    print "request.GET('stage') == 'pd' "
    """ Render post deposit homepage """
    context['html'] = render_to_string('costing/report2_ccis.html', context)
    print "'render_to_sting() called with parameter: costing/report2_ccis.html "
    context['active_tab'] = '4'
    print "render() called with parameter: costing/reports_post_deposit.html "
    return render(request, 'costing/reports_post_deposit.html', context)
else:
    print "request.GET('stage') != 'pd' "
    """ Render pre deposit homepage """
    context['html'] = render_to_string('costing/report_ccis.html', context)
    context['post_deposit'] = True
    print "'render_to_sting() called with parameter: costing/report_ccis.html "
    context['active_tab'] = '5'
    print "render() called with parameter: costing/reports_pre_deposit.html "
    return render(request, 'costing/reports_pre_deposit.html', context)

In template pdf2_base.html check post_deposit value and display required column:

...
{% if post_deposit %}
    <th>Latest sum (£)</th>
{% endif %}
...
{% if post_deposit %}
    <td {% if item.final_cost == item.initial_cost %}style="color:blue;"{% endif %}>{{item.final_cost|money}}</td> 
{% endif %}
...
{% if post_deposit %}
    <td>{{cci_total_exc|money:'£'}}</td>
{% endif %}
...

0👍

you can send a context variable to decide whether to render block.super or not

👤rsb

Leave a comment