Creating a Quote form in Django
<p>i am creating a django powered website. Specifically, a courier website. I need to create an application that serves as a quoting app. The user will type in the dimensions of the package into a form and after submitting the form, a price/quote will be returned , based on the dimensions inputted.</p>

<p>I have done this so far 
(views.py)</p>

<pre><code>from django.shortcuts import render, redirect
from quote.forms import QuoteForm

    def quoting(request):
        if request.method == 'GET':
            form = QuoteForm()
        else:
            form = QuoteForm(request.POST)
            if form.is_valid():
                Length = form.cleaned_data['Length']
                Breadth = form.cleaned_data['Breadth']
                Height = form.cleaned_data['Height']

                return redirect('thanks')
        return render(request, "quote/quote.html", {'form': form})
</code></pre>

<p>(forms.py)</p>

<pre><code>from django import forms

class QuoteForm(forms.Form):

    Length = forms.Integer()
    Breadth = forms.Integer()
    Height= forms.Integer()
</code></pre>

<p>(quote.html)</p>

<pre><code>{% extends "shop/base.html" %}
{% block content %}
&lt;form method="post"&gt;
    {% csrf_token %}
    {{ form }}
    &lt;div class="form-actions"&gt;
      &lt;button type="submit"&gt;Send&lt;/button&gt;
    &lt;/div&gt;
&lt;/form&gt;
{% endblock %}
</code></pre>

<p>Then i am aware i am lacking an html that would display the answer. I am not sure how to do this.</p>

<p>The price is determined by:</p>

<p>price= Shipping weight X distance
shipping weight= (length X breadth X height) / 5000</p>

<p>Thanks in advance :)</p>

<p>You have redirected to a 'thanks' page after the input is received. You should not have to return anything at this point.</p>

<p>After you have the input of length, breadth and height. You can calculate the price by doing: (Length * Breadth * Height )/ 5000.</p>

<p>This can be stored into a variable 'total_price'. Then, add 'total_price' to your context when rendering. </p>

<p>Finally, in the HTML, you can add a Django template tag like </p>

<pre><code>{% if total_price %}
   {{ total_price }}
{{ else }}
   {{ form }}
</code></pre>

<p>Hope this helps!</p>

python html django rest