# Shortcut for `python manage.py` in Django

Life is too short to keep typing `python manage.py` before every command in Django. 

```bash
(venv) $ python manage.py runserver
(venv) $ python manage.py migrate
(venv) $ python manage.py makemigrations
```

You can use one of these solutions to simplify things.

## Using the Django shortcuts package
The [Django shortcuts](https://pypi.org/project/django-shortcuts/) package from PyPi is the silver bullet to this problem. All you need to do is install locally.
```bash
pip install django-shortcuts
```
And voila you can prepend Django to single letters

```bash
'c'  : 'collectstatic', # django c
'r'  : 'runserver',
'sd' : 'syncdb',
'sp' : 'startproject',
'sa' : 'startapp',
't'  : 'test',
```

If you'll like to learn a thing or two about shell scripts and aliases, you can use the methods below.

## Using a shell script
### Steps 
1. Create a django file in bin
```bash
sudo nano /bin/django
```
You can use an alternate text editor like gedit or vi.
2. Add this code to the file
```bash
#!/bin/bash
python manage.py "$@"
```
3. Make the file executable
```bash
$ sudo chmod a+x /bin/django
```
4. Run any command you wish 
```bash
(venv) $ django runserver
(venv) $ django migrate
(venv) $ django makemigrations
```

Much easier eh? 

## Using a bash alias
You can use a bash alias to achieve the same thing. 
### Steps
1. Open the bashrc file using a text editor
```bash
$ gedit ~/.bashrc
```
2. Add this function to the file
```bash
django(){
	python manage.py "$@"
}
```
3. Save the file
4. Open a new terminal (doesn't take effect in previously open terminals)
5. Try the commands
```bash
(venv) $ django runserver
(venv) $ django migrate
(venv) $ django makemigrations
```

Please subscribe to my newsletter to never miss a post. Thanks for reading. Adios ✌🏾🧡.


