About Caffeinated Program Runs

MacOS has a utility program caffeinate which can prevent the computer from sleeping at a wrong time.

You can run it like this in the Terminal while watching a long video:

$ caffeinate

Or you can run Django management commands with it like this to prevent sleeping while you access the local website on a smart phone:

(.venv)$ caffeinate -dimsu python manage.py runserver \
0.0.0.0:8000 --noreload

The caffeinate parameters are as follows:

  • -d - keep screen awake.
  • -i - prevent idle sleep.
  • -m - prevent disk sleep.
  • -s - prevent system sleep (on power).
  • -u - simulate activity.

That's basically: "don't sleep under any condition while running".

Tips and Tricks Developer Experience Django 6.x Django 5.2 Django 4.2 macOS

Django/Python Consulting

If you have a specific Django challenge or integration you'd like to solve, I'd be happy to help. Book a free 30-minute call to discuss your project, see if we're a good fit, and explore the best approach for your needs. After the call, you'll receive a tailored cost estimate based on what we discuss.