Python Django Configuration Mac Terminal

After installing Python3

On Terminal ($) to check the version of python which is installed


$ Python -V
$ Python3 - V

To install pip


$ sudo easy_install pip

To install virtualenv try the code below


$ pip install virtualenv
# If the command returns permission error - try installing only for the #particular user -
pip install virtualenv --user

Setup virtual environment


python -m virtualenv venv

To activate virtual enviroment


source venv/bin.activate

Within the environment, install the Django package using pip. Installing Django allows us to create and run Django applications.

pip install Django

To check Django version after installation


django-admin --version

Django-admin is the command will allow to use all sort of things on Django


Django-admin

To create a Django project on the same directory use the command below. Note the ‘.’ too specify that to create the start project on the directory that we are in.


django-admin startproject trydjando .

To start the development server (which will start a development server at http://127.0.0.1:8000/


Python manage.py runserver

To kill the development server incase default port 8000 error

sudo fuser -k 8000/tcp. This should kill all the processes associated with port 8000.

For osx users you can use sudo lsof -t -i tcp:8000 | xargs kill -9

To link to database DATABASES on the settings.py file

Python manage.py migrate

To create a admin for the server (ex. default web portal http://127.0.0.1:8000/admin)


python manage.py createsuperuser

To change the password for the admin

python manage.py changepassword

Leave a comment