2๐
โ
I figured out how to run it without changing the script and thatโs by using
python manag.py shell
and then
exec(open('filename').read())
that seemed to work just fine.
๐คmari
0๐
I would recommend using Django Custom Management Commands โ they are really simple to use, they use your settings, your environment, you can pass parameters and also you can write help strings so you can use --help
Then you just call it with ./manage.py my_custom_command
Or if you just want to run your script add this to the your script
project_path = '/home/to/your/trailers/project/src'
if project_path not in sys.path:
sys.path.append(project_path)
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "trailers.common")
import django
django.setup()
๐คsebb
Source:stackexchange.com