Hacker News new | ask | show | jobs
by yen223 2439 days ago
Without calling setup, you cannot import anything that touches Django models, like constants defined in a file that transitively imports a Django model.

In practice, this means that any script that depends indirectly on Django code will incur a lengthy startup cost (from having to call setup()), and will fail to run if there's no database connection, even if the script itself doesn't need the db.

1 comments

You can import Django models before calling setup, you will simply not be able to use the database before calling setup.