While developing I use print() statements (with f-strings) but the not all the output is sent to the console.
When I hit ctrl-c and kill the server - I can see all that is printed but when it’s running I don’t always see every statement that should be printing.
I assume there is some sort of timing issue here - is there a way to force the server that comes with Django to print out all the print() statements?
P.S. Yes I know I should be using logging - but the world is not a perfect place.
I’m guessing you’re using manage.py runserver to run your code during development. If so, I’ve also encountered this in the past.
What has worked for me has been to disable output buffering in the python instance by running manage with the -u parameter. In other words, your command would look something like this:
python -u manage.py runserver
Another similar option would be to set the PYTHONUNBUFFERED environment variable to any non-empty string.