Created
November 17, 2018 08:13
-
-
Save manjurulhoque/62a2961b2d648298e4fdd9f9e2f9f16b to your computer and use it in GitHub Desktop.
Run python script from django shell
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| For python3 you would need to use | |
| >>> exec(open('myscript.py').read()) | |
| or | |
| import os, django | |
| os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings") | |
| django.setup() | |
| # now your code can go here... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment