[Answered ]-How to add script to Django app?

2👍

You should use the Django shell to run scripts within a Django project. You can start the shell by typing:

python manage.py shell

at the OS command prompt while you are in your project root. You can just import web_crawler.py since you don’t have a main method:

>>> from scraper import web_crawler.py

That being said, the better way to run a script that should access to the Django environment would be to write it as a management command. That way, you can run it using

python manage.py <mycommand>

See https://docs.djangoproject.com/en/1.7/howto/custom-management-commands/ for details.

👤Selcuk

Leave a comment