title: Can I call an function from another function in Django views.py?
body: <p>I have created two functions in my views.</p>
  <p><code>def Covid_view()</code> - this one will fetch all covid data from an api.</p>
  <p>Another function is <code>def home()</code>. Inside this function I want to call covid_view() which will return me data that I can pass in my template.</p>
  <p>Below is my code:</p>
  <p><strong>Views.py</strong></p>
  <pre><code>from django.shortcuts import render
  import requests
  
  # this function is just to call api and get data of covid
  def covid_data():
      api_response = requests.get('https://covid19.mathdro.id/api/countries/india')
      covid_data = (api_response.json())
      trim_last_update = covid_data['lastUpdate']
      trimmed_date = trim_last_update.find('T') # Here I'm trimming date_time string to show only date. T was for time to I split till T and store prior string
      res_trimmed_date = trim_last_update[:trimmed_date] # This will print string till T but not T and afterwards
      confirmed = covid_data['confirmed']
      recovered = covid_data['recovered']
      deaths = covid_data['deaths']
      context = {
          'res_trimmed_date': res_trimmed_date,
          'confirmed': confirmed['value'],
          'recovered': recovered['value'],
          'deaths': deaths['value']
      }
      return context
  
  
  def index(request):
      # here I want to call this function which must return me data so I can pass it to my template
      data = covid_data()
      return render(request, 'covidStatsApp/index.html', data)
  
  </code></pre>
  <p>When I tried to run it gives me error like even though I tried to pass request as well.</p>
  <pre><code>TypeError at /
  covid_data() missing 1 required positional argument: 'request'
  </code></pre>