Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

community creator

How to skip `python` from every command in Django

Osinachi Chukwujama

Life is too short to keep typing python before every command in Django. Instead, you can use of the following solutions to simplify things:

(venv) $ python runserver
(venv) $ python migrate
(venv) $ python makemigrations

Using the Django shortcuts package

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.

Using a shell script


  1. Create a Django file in bin:
sudo nano /bin/django

You can use an alternate text editor like gedit.

  1. Add this code to the file:
python "$@"
  1. Make the file executable:
$ sudo chmod a+x /bin/django
  1. Run any command you wish:
(venv) $ django runserver
(venv) $ django migrate
(venv) $ django makemigrations

Using a bash alias

You can use a bash alias to achieve the same thing.


  1. Open the bashrc file using a text editor:
$ gedit ~/.bashrc
  1. Add this function to the file:
 python "$@"
  1. Save the file.

  2. Open a new terminal (won’t take effect in previously opened terminals).

  3. Try the commands:

(venv) $ django runserver
(venv) $ django migrate
(venv) $ django makemigrations


community creator


Osinachi Chukwujama
Copyright ©2022 Educative, Inc. All rights reserved

View all Courses

Keep Exploring