title: django , requests download file
body: <p>I am trying to download a file from another server, I want to save it in a local server and create a download link, so that user would be able to download it from our website.</p>
  
  <p>I can download it with requests, it works fine but I don't have idea how to save the file in static files directory  and create a <em>url</em> for it. Guide me please</p>
  
  <pre><code>import requests
  def download_file(url):
     local_filename = url.split('/')[-1]
     r = requests.get(url, stream=True)
     with open(local_filename, 'wb') as f:
      for chunk in r.iter_content(chunk_size=1024):
          if chunk: # filter out keep-alive new chunks
              f.write(chunk)
  return local_filename
  </code></pre>