|
1 ===================== |
|
2 How to install Django |
|
3 ===================== |
|
4 |
|
5 This document will get you up and running with Django. |
|
6 |
|
7 Install Python |
|
8 ============== |
|
9 |
|
10 Being a Python Web framework, Django requires Python. |
|
11 |
|
12 It works with any Python version 2.3 and higher. |
|
13 |
|
14 Get Python at www.python.org. If you're running Linux or Mac OS X, you probably |
|
15 already have it installed. |
|
16 |
|
17 Install Apache and mod_python |
|
18 ============================= |
|
19 |
|
20 If you just want to experiment with Django, skip this step. Django comes with |
|
21 its own Web server for development purposes. |
|
22 |
|
23 If you want to use Django on a production site, use Apache with `mod_python`_. |
|
24 mod_python is similar to mod_perl -- it embeds Python within Apache and loads |
|
25 Python code into memory when the server starts. Code stays in memory throughout |
|
26 the life of an Apache process, which leads to significant performance gains |
|
27 over other server arrangements. Make sure you have Apache installed, with the |
|
28 mod_python module activated. Django requires Apache 2.x and mod_python 3.x. |
|
29 |
|
30 See `How to use Django with mod_python`_ for information on how to configure |
|
31 mod_python once you have it installed. |
|
32 |
|
33 If you can't use mod_python for some reason, fear not: Django follows the WSGI_ |
|
34 spec, which allows it to run on a variety of server platforms. See the |
|
35 `server-arrangements wiki page`_ for specific installation instructions for |
|
36 each platform. |
|
37 |
|
38 .. _Apache: http://httpd.apache.org/ |
|
39 .. _mod_python: http://www.modpython.org/ |
|
40 .. _WSGI: http://www.python.org/peps/pep-0333.html |
|
41 .. _How to use Django with mod_python: ../modpython/ |
|
42 .. _server-arrangements wiki page: http://code.djangoproject.com/wiki/ServerArrangements |
|
43 |
|
44 Get your database running |
|
45 ========================= |
|
46 |
|
47 If you plan to use Django's database API functionality, you'll need to |
|
48 make sure a database server is running. Django works with PostgreSQL_ |
|
49 (recommended), MySQL_ and SQLite_. |
|
50 |
|
51 Additionally, you'll need to make sure your Python database bindings are |
|
52 installed. |
|
53 |
|
54 * If you're using PostgreSQL, you'll need the psycopg_ package (version 2 is |
|
55 recommended with ``postgresql_psycopg2`` backend, version 1.1 works also with the |
|
56 ``postgresql``` backend). |
|
57 |
|
58 If you're on Windows, check out the unofficial `compiled Windows version`_. |
|
59 |
|
60 * If you're using MySQL, you'll need MySQLdb_, version 1.2.1p2 or higher. |
|
61 |
|
62 * If you're using SQLite, you'll need pysqlite_. Use version 2.0.3 or higher. |
|
63 |
|
64 .. _PostgreSQL: http://www.postgresql.org/ |
|
65 .. _MySQL: http://www.mysql.com/ |
|
66 .. _Django's ticket system: http://code.djangoproject.com/report/1 |
|
67 .. _psycopg: http://initd.org/tracker/psycopg |
|
68 .. _compiled Windows version: http://stickpeople.com/projects/python/win-psycopg/ |
|
69 .. _MySQLdb: http://sourceforge.net/projects/mysql-python |
|
70 .. _SQLite: http://www.sqlite.org/ |
|
71 .. _pysqlite: http://initd.org/tracker/pysqlite |
|
72 |
|
73 Install the Django code |
|
74 ======================= |
|
75 |
|
76 Installation instructions are slightly different depending on whether you're |
|
77 using the latest official version or the latest development version. |
|
78 |
|
79 It's easy either way. |
|
80 |
|
81 Installing the official version |
|
82 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
83 |
|
84 1. Check the `distribution specific notes`_ to see if your |
|
85 platform/distribution provides official Django packages/installers. |
|
86 Distribution-provided packages will typically allow for automatic |
|
87 installation of dependancies and easy upgrade paths. |
|
88 |
|
89 2. Download Django-0.95.tar.gz from our `download page`_. |
|
90 |
|
91 3. ``tar xzvf Django-0.95.tar.gz`` |
|
92 |
|
93 4. ``cd Django-0.95`` |
|
94 |
|
95 5. ``sudo python setup.py install`` |
|
96 |
|
97 Note that the last command will automatically download and install setuptools_ |
|
98 if you don't already have it installed. This requires a working Internet |
|
99 connection and may cause problems on Python 2.5. If you run into problems, |
|
100 try using our development version by following the instructions below. The |
|
101 development version no longer uses setuptools nor requires an Internet |
|
102 connection. |
|
103 |
|
104 The command will install Django in your Python installation's ``site-packages`` |
|
105 directory. |
|
106 |
|
107 .. _setuptools: http://peak.telecommunity.com/DevCenter/setuptools |
|
108 .. _distribution specific notes: ../distributions/ |
|
109 |
|
110 Installing the development version |
|
111 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
|
112 |
|
113 If you'd like to be able to update your Django code occasionally with the |
|
114 latest bug fixes and improvements, follow these instructions: |
|
115 |
|
116 1. Make sure you have Subversion_ installed. |
|
117 2. Check out the Django code into your Python ``site-packages`` directory. |
|
118 On Linux / Mac OSX / Unix, do this:: |
|
119 |
|
120 svn co http://code.djangoproject.com/svn/django/trunk/ django_src |
|
121 ln -s `pwd`/django_src/django /usr/lib/python2.3/site-packages/django |
|
122 |
|
123 (In the above line, change ``python2.3`` to match your current Python version.) |
|
124 |
|
125 On Windows, do this:: |
|
126 |
|
127 svn co http://code.djangoproject.com/svn/django/trunk/django c:\Python24\lib\site-packages\django |
|
128 |
|
129 3. Copy the file ``django_src/django/bin/django-admin.py`` to somewhere on your |
|
130 system path, such as ``/usr/local/bin`` (Unix) or ``C:\Python24\Scripts`` |
|
131 (Windows). This step simply lets you type ``django-admin.py`` from within |
|
132 any directory, rather than having to qualify the command with the full path |
|
133 to the file. |
|
134 |
|
135 You *don't* have to run ``python setup.py install``, because that command |
|
136 takes care of steps 2 and 3 for you. |
|
137 |
|
138 When you want to update your copy of the Django source code, just run the |
|
139 command ``svn update`` from within the ``django`` directory. When you do this, |
|
140 Subversion will automatically download any changes. |
|
141 |
|
142 .. _`download page`: http://www.djangoproject.com/download/ |
|
143 .. _Subversion: http://subversion.tigris.org/ |