Life is too short to keep typing python manage.py
before every command in Django. Instead, you can use of the following solutions to simplify things:
(venv) $ python manage.py runserver
(venv) $ python manage.py migrate
(venv) $ python manage.py makemigrations
The Django shortcuts package from PyPi is the silver bullet to this problem. All you need to do is install locally,
$ pip install django-shortcuts
And voila! You can prepend Django to single letters:
'c' : 'collectstatic', # django c 'r' : 'runserver', 'sd' : 'syncdb', 'sp' : 'startproject', 'sa' : 'startapp', 't' : 'test',
If you’d like to learn a thing or two about shell scripts and aliases, you can use the following methods.
Steps
sudo nano /bin/django
You can use an alternate text editor like gedit.
#!/bin/bash
python manage.py "$@"
$ sudo chmod a+x /bin/django
(venv) $ django runserver
(venv) $ django migrate
(venv) $ django makemigrations
You can use a bash alias to achieve the same thing.
Steps
$ gedit ~/.bashrc
django(){
python manage.py "$@"
}
Save the file.
Open a new terminal (won’t take effect in previously opened terminals).
Try the commands:
(venv) $ django runserver
(venv) $ django migrate
(venv) $ django makemigrations
Free Resources