Unos apuntes rĂĄpidos para instalar y configurar Django y un servidor de bases de datos PostgreSQL en Mac. Python ya viene instalado en Mac OS X, asĂ que no tendremos que tocarlo.
Django
First of all we need to install setuptools as described here. To do this, we download the ez_setup.py file and execute it (placing ourselves in the directory in which it is located) from the Terminal by entering:
python ez_setup.py
Once this is done, we will have to install pip first downloading from this page the file get-pip.py. Then in the Terminal we will run the downloaded file with the following command to install it:
python get-pip.py
Once pip is installed, we can install Django (The latest version may be different from the one that appears in the command below, check it here).
sudo pip install Django==1.6.1
Once this is done, Django will now be installed and we can create our first application in the directory of our choice (We may have to close and reopen the Terminal):
django-admin.py startproject
PostgreSQL
To install PostgreSQL and make it work with Django we need to install two things: on the one hand the database server with the database and on the other the Django module in charge of interacting with the database (psycopg2).
The simplest and least intrusive way to install the DB server (I have not found information on how to uninstall the official version) is to use the Postgres.app application. By simply running it, we will have our DB server working without problems.
Once installed, we will have to add the applicationâs executables directory to the systemâs PATH. To do this, from the Terminal we will enter the following commands.
We will run a text editor to modify the content of the PATH:
sudo nano /etc/paths
We will add a line to the end of the file that refers to the content of the application:
/Applications/Postgres93.app/Contents/MacOS/bin
Once entered we will press âctrl+xâ to exit and then âyâ to save.
If we write the following command in the Terminal, the line we entered should appear:
echo $PATH
Now we can install the Django psycopg2 module from pip:
sudo pip install psycopg2
Once done, we will have both Django and PostgreSQL installed and we can start developing.