Running a Django app from command line

Have you tried to run a Django app from command line, like a script?
The StackOverflow has a useful tip for that:

import os, sys

if __name__ == '__main__':
# Setup environ
sys.path.append(os.getcwd())
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "main.settings")

# Setup django
import django django.setup()

Read more …

Stackoverflow: https://stackoverflow.com/questions/32088702/using-django-for-cli-tool

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *