You can create a custom shell command (like a one-word alias) to run your Django server with your virtual environment activated. Here’s how to do it step-by-step:
✅ 1. Create a Script File
Make a small shell script, for example:
bashCopyEditnano ~/startserver.sh
Paste this inside:
bashCopyEdit#!/bin/bash
cd /full/path/to/your/project/
source venv/bin/activate
cd client_portal/
python3 manage.py runserver 0.0.0.0:8000
deactivate
Replace
/full/path/to/your/project/
with the actual path to your project folder.
✅ 2. Make It Executable
bashCopyEditchmod +x ~/startserver.sh
✅ 3. Create a One-Word Command
Now add an alias to your .bashrc
or .zshrc
:
bashCopyEditnano ~/.bashrc
Add this at the bottom:
bashCopyEditalias startserver="~/startserver.sh"
Then reload it:
bashCopyEditsource ~/.bashrc
✅ Now You Can Just Run:
bashCopyEditstartserver
From anywhere in your terminal. Let me know if you want a version that runs in the background or logs output.