title: How to get the context of one view to another view in Django
body: <p>I want to add context in my create_form view but I get </p>
  
  <blockquote>
    <p>UnboundLocalError: local variable 'range' referenced before assignment</p>
  </blockquote>
  
  <p>The context of create_form view should available in create_test_bills. </p>
  
  <pre><code>from django.shortcuts import render, redirect
  from .forms import TestForm
  from .models import Test
  from django.template.loader import get_template
  from django.http import HttpResponse
  
  from project.utils import render_to_pdf 
  
  def create_form(request):
      if request.method == 'POST':
          range = request.POST.get('range')
          results = request.POST.get('results')
          unit = request.POST.get('unit')
          print(range,results,unit)
          return redirect('test_bills')
  
      return render(request,'form.html',{})    
  
  
  def create_test_bills(request,*args, **kwargs):
  
      if request.method == 'POST':
          range = request.GET.get('range')
          results = request.GET.get('results')
          unit = request.GET.get('unit')
      pdf = render_to_pdf('invoice.html',{'range':range,'results':results,'unit':unit,})
  
      return HttpResponse(pdf, content_type='application/pdf')
  </code></pre>
  
  <p>My template for form.html . I have included some fields required .</p>
  
  <pre><code>&lt;form method="POST"&gt;
      {% csrf_token %}
      &lt;div class="container"&gt;
        &lt;input type="text" placeholder="Range" name="range" required&gt;
        &lt;input type="text" placeholder="Results" name="results" required&gt;
        &lt;input type="text" placeholder="Unit" name="unit" required&gt;
        &lt;button type="submit" class="registerbtn"&gt;Register&lt;/button&gt;
      &lt;/div&gt;
    &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>