Desktop notifications when your server reloads — Django

End your anxiety from staring at your terminal for too long

Ícaro
Lemon Code
Published in
2 min readMay 22, 2019

--

Photo by Mihai Surdu on Unsplash, snippet by @carbon_app
Photo by Mihai, snippet from @carbon_app

Here’s a quickie. It can be annoying to keep looking at your terminal, waiting for your server to reload every time you make changes to your code, specially on bigger projects that it takes a handful of seconds for this process to finish.

If you are on Mac, I have a cool tip to improve this by using the pync library that wraps the OS’s Notification Center.

The trick is to monkey-patch Django’s loading process and inject the notification code at the moment that the server is loaded and ready to go.

(I recommend you to do this is in your local.py file because this will ensure that you don’t impose it to your project’s peers 😉)

With this set up, every time Django says “System check identified no issues” a notification will pop in your screen (followed by a distinct sound) so you will know for sure that you can access your development server, reload the views you are testing or continue doing whatever you need to reload your server for.

Close reddit and get back to work!

All the source code shown and explained here (mixins, functions, examples, samples, etc.) is available in the GitHub repository below along with other helpful projects I’ve developed and wrote about. Feel free to check it out, use them in your own work and help me improve them with your feedback.

🍋 🍋 🍋

--

--