How-To: Manually restart django development server

Here is how:

1. Script

Create a bash script, let’s say, ~/ and copy-paste following code:

2. Run

By running this script we can trick django development server into restarting it-self. To run:

bash ~/

If you are asked to enter password every-time, you can change file permissions to avoid that. To change file permissions run:

sudo chmod 700 ~/

3. Alias

Since we will be running this script a lot we can add an alias to help us easily run this. To add an alias, if using bash terminal, run:

echo "alias rst='bash ~/'" >> ~/.bashrc

To add an alias, if using zsh terminal, run:

echo "alias rst='bash ~/'" >> ~/.zshrc

Don’t forget to either source your rc file or restart your terminal for alias to work.