# Return submitted form results back to the same html page

**URL:** <https://forum.djangoproject.com/t/return-submitted-form-results-back-to-the-same-html-page/3702>\
**Category:** Using Django\
**Created:** [August 1, 2020, 10:26am UTC](https://forum.djangoproject.com/t/return-submitted-form-results-back-to-the-same-html-page/3702 "2020-08-01T10:26:08Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwatt](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/dwatt/32/7723_2.png) [@dwatt](https://forum.djangoproject.com/u/dwatt)\
**Post date:** [August 1, 2020, 10:26am UTC](https://forum.djangoproject.com/t/return-submitted-form-results-back-to-the-same-html-page/3702/1 "2020-08-01T10:26:09Z")

</div>

Hi,

I have a form which submits three values through a function and I’m trying to get those results printed on the same html page where the form is. I can print the results in the terminal but not on the page.

Forms, Views, and HTML below. Thanks!

Forms:

```
from django import forms

class CalculatorForm(forms.Form):
    value1 = forms.FloatField(required=False)
    value2 = forms.FloatField(required=False)
    value3 = forms.IntegerField(required=False)

```

Views:

```
class CalculatorView(TemplateView):
    template= 'calculator/calculator.html'

    def get(self, request):
        form_c = CalculatorForm(prefix='form_c')
        return render(request, self.template, {
            'form_c': form_c,
        })

    def post(self, request):
        form_c = CalculatorForm(request.POST, prefix='form_c')
        try:
            if form_c.is_valid():
                post = form_c.cleaned_data
                value1 = post.get('value1')
                value2 = post.get('value2')
                value3 = post.get('value3')
                df1 = my_function(value1, value2, value3) # I want to print the results of this function on the page
                print(df1)

        except:
            pass

        args = {
            'form_c': form_c,
        }
        return render(request, self.template, args)

```

HTML:

```
{% extends 'base.html' %}
<h1>Home Page</h1>

{% block head %}
<title>Check</title>
{% endblock %}
{% block body %}
<div class="container">
      <h3>Calculator</h3>
      <form method="post">
          {% csrf_token %}
          {{ form_c.as_p }}
          <button type="submit">Submit</button>
</div>
<div class="container">
    # my_function results here <---
    {% endblock %}
```

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [August 1, 2020, 1:28pm UTC](https://forum.djangoproject.com/t/return-submitted-form-results-back-to-the-same-html-page/3702/2 "2020-08-01T13:28:09Z")

</div>

You need to include the calculated value in your context, then include a variable reference in your template to render that value.
