Django

Django manage.py shell でpythonスクリプトファイルの内容を実行する

$ python manage.py shell

とやった後、事前に書いたpythonスクリプトファイル(例えば、プロジェクトディレクトリから一階層上のmyscript.py)を読み込ませたいとき

$python manage.py shell
>>> exec(open('../myscript.py').read())

How to execute a Python script from the Django shell?

You're not recommended to do that from the shell - and this is intended as you shouldn't really be executing random scripts from the django environment (but there are ways around this, see the other answers).

-Django
-

© 2022 yshystsj.com Powered by AFFINGER5