title: Passing parameter from function to another function in Django
body: <p>I have these two functions in <code>views.py</code> namely: <code>create_excel</code> and <code>section_landpins</code>.</p>
  
  <p><code>section_landpins</code>:</p>
  
  <pre><code>def section_landpins(request):
      if request.method == "GET":
          get_id = request.user.id
          pnt = ButuanMaps.objects.get(clandpin='162-03-0001-017-33').geom
          kmdistance = request.GET.get('kmtocity', default=100)
          mysection = request.GET.get('mysection', default='All')
          getarea = request.GET.get('getarea', default=5500000)
          getvalue = request.GET.get('mysoiltype', default=0)
          getvalue1 = request.GET.get('myerosion', default=0)
  
          args = []
          kwargs = {
              'landproperty__sownerid__id': get_id,
              'geom__distance_lte': (pnt, D(km=kmdistance)),
              'narea__lte': getarea
          }
  
          if mysection != 'All':
              kwargs['ssectionid__id'] = mysection
  
          if getvalue != '0':
              args.append(Q(geom__intersects=SoilType.objects.get(id=getvalue).geom))
  
          if getvalue1 != '0':
              args.append(Q(geom__intersects=ErosionMap.objects.get(id=getvalue1).geom))
  
          #this queryset below, I want this to be pass to `create_excel` function
          m = ButuanMaps.objects.filter(*args, **kwargs).values_list('clandpin')
          return HttpResponse(json.dumps(list(m)), content_type='application/json')
  </code></pre>
  
  <p>I wanted to pass the variable <code>m</code> to another function to filter my excel file.</p>
  
  <p>Here is the <code>create_excel</code>:</p>
  
  <pre><code>def create_excel(request):
      book = xlwt.Workbook(encoding='utf8')
      sheet = book.add_sheet('untitled')
  
      default_style = xlwt.Style.default_style
      datetime_style = xlwt.easyxf(num_format_str='dd/mm/yyyy hh:mm')
      date_style = xlwt.easyxf(num_format_str='dd/mm/yyyy')
  
      headers = [f.name for f in SOMEMODELHERE._meta.fields]
      #values should have the query of m from `section_landpins`
      values = LandProperty.objects.all().values_list()
      values_list = [headers] + list(values)
  
      for row, rowdata in enumerate(values_list):
          for col, val in enumerate(rowdata):
              if isinstance(val, datetime):
                  style = datetime_style
              elif isinstance(val, date):
                  style = date_style
              else:
                  style = default_style
              sheet.write(row, col, val, style=style)
  
      response = HttpResponse(mimetype='application/vnd.ms-excel')
      response['Content-Disposition'] = 'attachment; filename=example.xls'
      book.save(response)
      return response
  </code></pre>
  
  <p>How to I get or pass the queryset <code>m</code> from <code>section_landpins</code> to <code>create_excel</code> function for me to filter the excel file result?</p>