1. Preparación

Usaremos Django Versión 1.8. Para empezar tenemos que hacer un poco de preparación.

1.1. Python

Django is written completely in Python. Therefore Python needs to be installed first.

Nota

Django 1.8 supports Python from version 2.7. If you have an older version of Python, you should update it. Django supports Python 3 since version 1.5.

You can find out which version of Python you’re running by using the command line option --version:

$ python --version
Python 2.7.6

Nota

If you are using Python 3 please make sure you have Python 3.3.2 or greater installed. Otherwise there will be problems.

Also consider adding the following future-import on top of every Python file you are going to edit to ensure Python 2 and 3 compatibility:

from __future__ import unicode_literals

This way all regular strings will be unicode string literals.

If you want to learn more read the Python 3 part of the Django documentation.

Si ya tienes la versión correcta de Python instalada, puedes saltar directamente a Gestores de paquetes Python.

1.1.1. Linux

Muchas distribuciones de Linux vienen con Python ya instalado. SI no tienes una versión de Python instalada, normalmente puedes usar tu gestor de paquetes para descargar e instalarlo.

Alternatively, you can get the Python Sources from the website and compile it yourself.

1.1.2. Mac OS X

Python comes pre-installed on Mac OS X. You can however use Homebrew to install your own copy of Python.

1.1.3. Windows

Download the Installer from the Python Website and install it.

Para que Python funcione en Windows como se espera, necesitas cambiar la variable de entorno %PATH%. En los ejemplos, asumiremos que Python está instalado en C:\Python27\.

1.1.3.1. Windows 7

  1. Start, luego clic derecho en Computer

  2. Ahora haz clic en la opción Propiedades del menú de contexto.

  3. A continuación en la ventana que se acaba de abrir, haz clic en :guilabel`Advanced System Settings`

  4. Se abrirá una ventana adicional, haz clic en Environment Variables

  5. Bajo System Variables, secciona la PATH

  6. Ahora haz clic en Edit y añade el directorio requerido: ;C:\Python27\;C:\Python27\Scripts;. (El punto y coma al principio son requeridos!)

  7. Ahora cierra las ventanas Environment Variables y System Properties haciendo clic en OK.

1.1.3.2. Windows XP

  1. Start ‣ Control Panel ‣ System ‣ Advanced
  2. Clic en Environment Variables, a continuación una nueva ventana se abrirá. En “Sytem Variables” seleciona Path

  3. Ahora haz clic en Edit y añade el directorio requerido: ;C:\Python27\;C:\Python27\Scripts;. (El punto y coma al principio son requeridos!)

  4. Ahora cierra las ventanas Environment Variables y System Properties haciendo clic en OK.

1.2. Gestor de Paquetes Python

Python has its own package system to manage distribution and installation of Python packages. Because we will need to install several packages, we must first make sure the package manager pip is installed. pip was originally written as an improvement of easy_install.

To decide which installation procedure is right for you check again your Python version:

$ python --version
Python 2.7.6

1.2.1. Python 3.4 and Python 2.7.9

If you have Python 3.4 or Python 2.7.9 (or newer) installed you can use ensurepip to install or upgrade pip:

$ python -m ensurepip --upgrade

If your Python version is too old you will simply see an error message like that:

$ python -m ensurepip --upgrade
/usr/bin/python: No module named ensurepip

1.2.2. Python 3.3 and Python 2

If you have Python 3.3 or Python 2 with a version lower than 2.7.9 installed, your Python installation does not contain the module ensurepip. In this case pip can be installed with the help from a bootstrap script. If curl is installed, you can use it to download pip at the command line. Otherwise just use the browser.

$ curl -O https://bootstrap.pypa.io/get-pip.py

When the bootstrap script has been downloaded execute it to install pip:

$ python get-pip.py

Nota

Under Linux and Mac OS X root privileges may be required. In this case use:

$ sudo python get-pip.py

Nota

If you have problems running get-pip.py because of the configuration of your internet connection please have a look the pip installation documentation.

Puedes eliminar el script de arranque cuando la instalación haya finalizado.

1.2.3. Test pip

After a successful upgrade or installation, you can test pip as follows:

$ pip --version
pip 7.0.1 from /Users/keimlink/.virtualenvs/django-marcador/lib/python2.7/site-packages (python 2.7)