[Fixed]-Django โ€“ passing data from a python script to a django view

1๐Ÿ‘

I recommend to split script.py into two parts:

  • a module that exposes a function that does something with model instances
  • a command that imports that module and runs the function with command-line arguments

Then you can just import the function both from the view and from the command-line script. A function call sounds more convenient and efficient compared to spawning a separate python process and passing all parameters through command line.

๐Ÿ‘คKos

Leave a comment