Use the Django ORM in a standalone script (again)

前端 未结 3 1500
情歌与酒
情歌与酒 2021-02-01 11:07

I\'m trying to use the Django ORM in some standalone screen scraping scripts. I know this question has been asked before, but I\'m unable to figure out a good solution for my pa

3条回答
  •  無奈伤痛
    2021-02-01 11:14

    I know this question is six years old but this alternative might appeal to someone searching this topic. Assuming Django's manage.py is in project/, and assuming main() is the script's entrypoint, then let Django take the strain:

    ./manage.py shell -c 'from scrape.test import main; main()'
    

提交回复
热议问题