title: When I am trying to execute django core management code in the function it doesn't work
body: <p>I need to upload cvs data to database and I wrote the code which did it. but I need to do it triggered: every time user upload file - the python script update the database. 
  In my code: I have call_command('uploadDb') when I place it not in function upload - it works, but when I place it inside the upload function - it didnt 
  What is the problem?
  Thank you </p>
  
  <pre><code>from django.shortcuts import render
  import os
  from django.core.management import call_command
  
  
  
  # Create your views here.
  from django.http import HttpResponse
  
  def index(request):
      return HttpResponse("&lt;h1&gt;Upload the file&lt;/h1&gt;")
  
  def home(request):
      return render(request, 'index.htm', {'what':'File Upload'})
  
  def upload(request):
      if request.method == 'POST':
          handle_uploaded_file(request.FILES['file'], str(request.FILES['file']))
          return HttpResponse("Successful")
  
      return HttpResponse("Failed")
  
  def handle_uploaded_file(file, filename):
      if not os.path.exists('upload/'):
          os.mkdir('upload/')
  
      with open('upload/' + filename, 'wb+') as destination:
  
          for chunk in file.chunks():
              destination.write(chunk)
  
  
  call_command('uploadDb')  
  </code></pre>
  
  <p>uploadDb function in /management/commands </p>
  
  <pre><code>from django.core.management.base import BaseCommand, CommandError
  from data.models import MyCsvModel
  from data.models import MyCsvModel2
  from data.models import MyCsvModel3
  from data.models import MyCsvModel4
  
  class Command(BaseCommand):
      help = 'Command to do import to database'
  
      def handle(self, *args, **options):
          try:
              my_csv_list = MyCsvModel.import_data(data = open("C:\\Users\\kz938vk\\Desktop\\client.csv"))
              my_csv_list2 = MyCsvModel2.import_data(data = open("C:\\Users\\kz938vk\\Desktop\\product.csv"))
              my_csv_list3 = MyCsvModel3.import_data(data = open("C:\\Users\\kz938vk\\Desktop\\payment.csv"))
              my_csv_list4 = MyCsvModel4.import_data(data = open("C:\\Users\\kz938vk\\Desktop\\messages.csv"))
              print("I am here")
              pass
          except Exception as e:
              CommandError(repr(e))
  </code></pre>