How to change "python manage.py" to "./manage.py"?

Viewed 385

I want to shorten python manage.py to ./manage.py.

This may be simple, but I couldn't find an answer for this. I saw a step by step method in one of the answers for questions about django but I did not memorize that. Tried to search for answers on stackoverflow to no avail.

Any help would be appreciated.

2 Answers

If you're on a Unix based system:

Make sure the file has the proper shebang (=this line) as the topmost line (it should have this by default already):

#!/usr/bin/env python

Make your script executable by running:

$ chmod u+x manage.py

After that you're good to go.

In order to do that, you will need to do two things:

  1. define the proper shebang [wiki] in the manage.py file; and
  2. make the file executable.

Normally the manage.py file already has a shebang at the top:

#!/usr/bin/env python

but depending on your system this might invoke instead of , you thus might want to change this to:

#!/usr/bin/env python3

If you make use of a virtual environment, you should let this point to the python executable of the virtual environment instead, so:

#!path/to/env/bin/python3

Next you make the file executable, you can do this with chmod:

chmod +x manage.py

or if you only want to make it executable by the owner of the manage.py file, you can use:

chmod u+x manage.py
Related