Running a Python script outside of Django

前端 未结 7 1990
后悔当初
后悔当初 2021-01-30 03:22

I have a script which uses the Django ORM features, amongst other external libraries, that I want to run outside of Django (that is, executed from the command-line).

Edi

7条回答
  •  不要未来只要你来
    2021-01-30 03:47

    Note that the suggestions around importing settings and using setup_environ have been deprecated with Django 1.4.

    There's a thread on the Django Github describing why this was done.

    There are still some other options out there but many of them seem hackish to me. My preferred method is often to include the scripted function as an extended command of manage.py

提交回复
热议问题