title: Running python script from django view with parameters
body: <p>I want to call a python script with paramters from django view. The python script is stored in a subfolder (see attached picture). </p>
  
  <p>Basically I have an input form and want to call crawl.py with the input data from that form. The form data should be stored in variable "production_number" in crawl.py.</p>
  
  <p><strong>view.py</strong></p>
  
  <pre><code>from .forms import CustomerForm, LoginForm
  from .models import Orders
  
  from .ERPProgramm.crawl import crawlmain
  
  def newOrders(request):
  
  if request.method == 'POST':
      form = CustomerForm(request.POST)
      if form.is_valid():
          formdata = form.cleaned_data['product_ID']
  
          # call crawl.py with paramter formdata 
  
          return HttpResponseRedirect('/customer/newOrders')
  </code></pre>
  
  <p><strong>crawl.py</strong></p>
  
  <pre><code>import db
  import sys
  import requests
  import json
  from datetime import datetime
  
  def query(resource):
      r = requests.get('http://11.111.11.11:8080/webapp/api/v1/' + resource,
          headers={'AuthenticationToken': '11111-11111-1111-1111-11111'}
      )
      return r
  
  
  costumer_id = 1
  production_number = formdata
  
  d = query('productionOrder/?productionOrderNumber-eq={}'.format(production_number)).json()
  
  session = db.Session()
  
  costumer = session.query(db.Costumer).get(costumer_id)
  
  if 'result' in d and len(d['result']) &gt; 0:
      r = d['result'][0]
      order = db.Order()
      try:
          order.article_id = r['articleId']
          order.amount = r['targetQuantity']
          order.create_date = datetime.fromtimestamp(r['createdDate'] / 1000)
          order.start_date = datetime.fromtimestamp(r['targetStartDate'] / 1000)
          order.end_date = datetime.fromtimestamp(r['targetEndDate'] / 1000)
      except NameError as e:
          sys.exit('Error {}'.format(e.what()))
  
      article_number = r['articleNumber']
      d = query('article/?articleNumber-eq={}'.format(article_number)).json()
  
      if 'result' in d and len(d['result']) &gt; 0:
          r = d['result'][0]
          article_image_id = r['articleImages'][0]['id']
          order.price_offer = r['articlePrices'][0]['price']
  
          r = query('article/id/{}/downloadArticleImage?articleImageId={}'.format(order.article_id, article_image_id))
  
          order.article_image = r.content
      else:
          print('No result for article with number', article_number)
  
      costumer.orders.append(order)
  
      session.add(costumer)
      session.commit()
  else:
      print('No result for production order with article number', article_number)
  </code></pre>
  
  <p>How can I call crawl.py from django view?</p>
  
  <p><a href="https://i.stack.imgur.com/abiYL.png" rel="nofollow noreferrer">Directory Overview</a></p>