| 1 | ================================ |
| 2 | How to install Django on Windows |
| 3 | ================================ |
| 4 | |
| 5 | This document will guide you through installing Django and Python for |
| 6 | basic usage on Windows. This is meant as a beginners guide for users doing |
| 7 | development of Django projects and does not reflect how Django should be |
| 8 | installed for production environments. |
| 9 | |
| 10 | Install Python |
| 11 | ============== |
| 12 | |
| 13 | Django is a Python web framework, thus requiring Python installed on your |
| 14 | machine. |
| 15 | |
| 16 | To install Python on your machine go to http://python.org/download/, and |
| 17 | download a Windows MSI installer for Python 2.x (eg. 2.7.1). Django does not |
| 18 | currently run on Python 3.x. lSee the :doc:`the Django FAQ </faq/install>` |
| 19 | for more information. |
| 20 | |
| 21 | Once downloaded, run the MSI installer and follow the on screen instructions. |
| 22 | |
| 23 | Install Setuptools |
| 24 | ~~~~~~~~~~~~~~~~~~ |
| 25 | |
| 26 | To install other python software on your computer, setuptools is needed. |
| 27 | Download the latest installer for your Python version from |
| 28 | http://pypi.python.org/pypi/setuptools#files. Run the installer and follow |
| 29 | the on screen instructions. |
| 30 | |
| 31 | Adding Python to PATH |
| 32 | ~~~~~~~~~~~~~~~~~~~~~ |
| 33 | |
| 34 | To be able to execute Python, and related scripts, the directory where |
| 35 | you installed Python, and the *Scripts* sub directory, |
| 36 | must be on PATH. Only the approach for Windows 7 will be explained, |
| 37 | but the other versions of Windows have similar approaches. |
| 38 | |
| 39 | * Click the Windows button. |
| 40 | |
| 41 | * Right click on *Computer* and choose *Properties*. |
| 42 | |
| 43 | * Click *Advanced System Settings* at the bottom of the list on the left side |
| 44 | of the opened window. |
| 45 | |
| 46 | * Click *Environment Variables* at the bottom |
| 47 | |
| 48 | * Find the *Path* variable in the list of *System variables*, |
| 49 | select it and click the *Edit...* button. |
| 50 | |
| 51 | * The *Variable value* is a semi colon separated list of directories. Make |
| 52 | sure both the install directory and the *Scripts* directory is in this list. |
| 53 | If not, add them to the end of the list (*C:\\Python27; |
| 54 | C:\\Python27\\Scripts*) |
| 55 | |
| 56 | * Click *OK* to save the changes. |
| 57 | |
| 58 | Install PIP |
| 59 | =========== |
| 60 | |
| 61 | `PIP <http://www.pip-installer.org/>`_ is a package manager for Python that |
| 62 | uses the `Python Package Index <http://pypi.python.org>`_ to install Python |
| 63 | packages. PIP will later be used to install Django from PYPI. |
| 64 | |
| 65 | * Open a command prompt. If you installed Python to a directory where only |
| 66 | administrators have write access, the command prompt need to be run as an |
| 67 | administrator user. |
| 68 | |
| 69 | * Execute the following command ``easy_install pip`` |
| 70 | |
| 71 | PIP should now be installed. |
| 72 | |
| 73 | Database |
| 74 | ======== |
| 75 | |
| 76 | From Python version 2.5 SQLite is included in the package. This means that, for |
| 77 | local development, it is normally not needed to install other databases. If |
| 78 | you want to use another database, like PostgreSQL, MySQL etc., |
| 79 | you are free to install it as well. |
| 80 | |
| 81 | Install Django |
| 82 | ============== |
| 83 | |
| 84 | Finally Django can be installed quite easily with PIP. |
| 85 | |
| 86 | In the same command prompt that you used to install PIP, |
| 87 | execute the following command: ``pip install django``. This will download and |
| 88 | install Django. |
| 89 | |
| 90 | After the installation has completed, you can verify your Django installation |
| 91 | by execution ``django-admin.py --version`` in the command prompt. |
| 92 | |
| 93 | Common pitfalls |
| 94 | =============== |
| 95 | |
| 96 | * If ``django-admin.py`` only displays the help text, no matter what arguments |
| 97 | it is given, there are probably a problem with the file association in |
| 98 | Windows. See the solution on `Stackoverflow <http://stackoverflow |
| 99 | .com/questions/2640971/windows-is-not-passing-command-line-arguments-to- |
| 100 | python-programs-executed-from-th>`_ |
| 101 | |