Django installation and configuration
Virtual environment for Django
First we need to create a virtual environment for Django.
We use the Anaconda-Navigator to create the base for the new environment. We also aim to use Nginx as an http and
reverse proxy server and uWSGI as a Web Server Interface Gateway. In Mac there is some
conflict with the versions (django, uwsgi, nginx) and therefore we need to use python version 3.5
in order to get a working setup.
First step: In the Anaconda-Navigator create
a new virtual environment based on Python 3.5 (we name here the new environment as virtual_environment).
The benefit of using the Anaconda-Navigator is that
it allows several python versions running simultaneously in one machine.
Add a PostgresSQL package (in Anaconda-Navigator)
psycopg2
Then go to the terminal window and activate the virtual environment
$ source activate virtual_environment
and add the following packages
$ pip install django
$ pip install uwsgi
The latter package uWSGI is needed for the communication between Django and Nginx. The virtual environment for the Django should now be ready to use.
Installation of Django
On Mac create a new directory where you want to install the Django, for example, a directory called Project.
Then go to this directory
$ cd Project
Then on the terminal window type
$ django-admin startproject mysite .
$ python manage.py startapp main
Django should now be installed. Type on the terminal window
$ python manage.py runserver
and on the browser type the link
http://127.0.0.1:8000/
You should now see the Django homepage.
Return to the
Mac main page.