score:0

Accepted answer

You need to return render(...) again after doing request.POST.

def growth(request):
    template_name = 'dashboard/growth.html'
    parsedData = []
    context = {'growth_json': parsedData, 'success': False}

    if request.method == 'POST':
        ...
        for data in parsed_json[data_input][year_input_int:]:
            growthData['date'] = data['date']
            growthData['value'] = data['value']
            growthData['year'] = data['year']
            parsedData.append(growthData.copy())

        context.update({'success': True})
        return render(request, template_name, context) # here
    return render(request, template_name, context)

and in your template;

{% if success %}
  {{ growth_json }}
{% endif %}

Related Query

More Query from same tag