Use the Django ORM in a standalone script (again)

前端 未结 3 1472
情歌与酒
情歌与酒 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:32

    Are you sure it shouldn't be:

    sys.path.append(os.path.join(os.path.abspath('..'), 'web'))
    

    Also, make sure there's an __init__.py file (empty is fine) in project/web/django_project.

    P.S. I'd recommend feeding os.path.join's output to os.path.abspath instead of the other way.

提交回复
热议问题