Description

I have some code in my project that generates some content for my pages (compiles documentation).

I would like this code to run once every time the server starts, and essentially I should use AppConfig.ready() to do this. However AppConfig.ready() also runs when I run any management command, which is very undesirrable, as I don't want to generate this content every time I run unrelated tasks, such as migrate.

Therefore it would be nice to have a flag or some other means to detect if code is currently running in the context a web server or not.

For now I have implemented this as a middleware which throws MiddlewareNotUsed after generating the content.

python manage.py runserver during development, but you make a valid point. Need to test if I can run my things there then, and then i guess developers must just run a management command manually to build documentation.