Changed tutorial2 to use 'django-admin runserver' instead of mod_python. Also updated WSGI mentions in the docs, now that we're WSGI-friendly.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@187 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Adrian Holovaty 2005-07-18 23:14:48 +00:00
parent 62cc287b2b
commit b55b29c891
3 changed files with 64 additions and 93 deletions

View File

@ -21,7 +21,6 @@ able to give something back to the open-source community.
.. _Python: http://www.python.org/
.. _PostgreSQL: http://www.postgresql.org/
What does "Django" mean, and how do you pronounce it?
-----------------------------------------------------
@ -120,13 +119,14 @@ How do I get started?
#. `Download the code`_.
#. Install Django (read the `installation guide`_).
#. Walk through the tutorial_.
#. Check out the rest of the documentation_, and ask questions if you
#. Check out the rest of the documentation_, and `ask questions`_ if you
run into trouble.
.. _`Download the code`: http://www.djangoproject.com/download/
.. _`installation guide`: http://www.djangoproject.com/documentation/install/
.. _tutorial: http://www.djangoproject.com/documentation/tutorial1/
.. _documentation: http://www.djangoproject.com/documentation/
.. _ask questions: http://www.djangoproject.com/community/
How do I fix the "install a later version of setuptools" error?
---------------------------------------------------------------
@ -136,7 +136,13 @@ Just run the ``ex_setup.py`` script in the Django distribution.
What are Django's prerequisites?
--------------------------------
Django requires Python_ 2.3 or later, `Apache 2`_, and mod_python_.
Django requires Python_ 2.3 or later.
For a development environment -- if you just want to experiment with Django --
you don't need to have a separate Web server installed; Django comes with its
own lightweight development server. For a production environment, we recommend
`Apache 2`_ and mod_python_, although Django follows the WSGI_ spec, which
means it can run on a variety of server platforms.
You'll also need a database engine. PostgreSQL_ is recommended, and MySQL_ is
supported.
@ -144,18 +150,32 @@ supported.
.. _Python: http://www.python.org/
.. _Apache 2: http://httpd.apache.org/
.. _mod_python: http://www.modpython.org/
.. _WSGI: http://www.python.org/peps/pep-0333.html
.. _PostgreSQL: http://www.postgresql.org/
.. _MySQL: http://www.mysql.com/
Do I have to use mod_python?
----------------------------
Not if you just want to play around and develop things on your local computer.
Django comes with its own Web server, and things should Just Work.
For production use, though, we recommend mod_python. The Django developers have
been running it on mod_python for about two years, and it's quite stable.
However, if you don't want to use mod_python, you can use a different server,
as long as that server has WSGI_ hooks. More information on alternate server
arrangements is forthcoming.
.. _WSGI: http://www.python.org/peps/pep-0333.html
How do I install mod_python on Windows?
---------------------------------------
* If you are running Python 2.4, check out this `guide to mod_python & Python 2.3`_.
* For Python 2.3, grab mod_python from http://www.mod_python.org/, the read
* For Python 2.4, check out this `guide to mod_python & Python 2.3`_.
* For Python 2.3, grab mod_python from http://www.mod_python.org/ and read
`Running mod_python on Apache on Windows2000`_.
* Also try this (not Windows-specific) `guide to getting mod_python working`_.
* Also, try this (not Windows-specific) `guide to getting mod_python working`_.
.. _`guide to mod_python & Python 2.3`: http://www.lehuen.com/nicolas/index.php/2005/02/21/39-win32-build-of-mod_python-314-for-python-24
.. _`Running mod_python on Apache on Windows2000`: http://groups-beta.google.com/group/comp.lang.python/msg/139af8c83a5a9d4f
@ -163,19 +183,12 @@ How do I install mod_python on Windows?
(Thanks to deelan for this info.)
Do I have to use mod_python?
----------------------------
In the first release, yes. However, WSGI_ support (which will let Django run
under FCGI, SCGI, medusa, etc.) is in the works. Stay tuned!
.. _WSGI: http://www.python.org/peps/pep-0333.html
Will Django run under shared hosting (like TextDrive or Dreamhost)?
-------------------------------------------------------------------
Right now, no, unless you can get your host to install mod_python. However, as
the previous answer says, WSGI support is coming!
the community starts to use Django's WSGI bindings with other Web servers, this
will probably be possible sooner rather than later.
Using Django
============
@ -244,4 +257,3 @@ be possible by editing the CSS stylesheet. We've got a `guide to the CSS used in
the admin`_ to get you started.
.. _`guide to the CSS used in the admin`: http://www.djangoproject.com/documentation/admin_css/

View File

@ -7,16 +7,20 @@ This document will get you up and running with Django.
Install Apache and mod_python
=============================
Currently, Django runs on Apache_ with `mod_python`_. mod_python is similar to
mod_perl -- it embeds Python within Apache and loads Python code into memory
when the server starts. Code stays in memory throughout the life of an Apache
process, which leads to significant performance gains over CGI.
If you just want to experiment with Django, skip this step. Django comes with
its own Web server for development purposes.
If you can't use mod_python for some reason, fear not: We're planning full WSGI_
support, which means Django will run on a variety of server platforms.
If you want to use Django on a production site, use Apache with `mod_python`_.
mod_python is similar to mod_perl -- it embeds Python within Apache and loads
Python code into memory when the server starts. Code stays in memory throughout
the life of an Apache process, which leads to significant performance gains
over other server arrangements. Make sure you have Apache installed, with the
mod_python module activated.
For the time being, make sure you have Apache installed, with the mod_python
module activated.
If you can't use mod_python for some reason, fear not: Django follows the WSGI_
spec, which allows it to run on a variety of server platforms. As people
experiment with different server platforms, we'll update this document to
give specific installation instructions for each platform.
.. _Apache: http://httpd.apache.org/
.. _mod_python: http://www.modpython.org/

View File

@ -25,78 +25,36 @@ interface for site administrators to edit content.
The admin isn't necessarily intended to be used by site visitors; it's for site
managers.
Expose the admin media files
Start the development server
============================
Django's admin is intended to be fully functional and good looking. For that
reason, Django ships with admin media files -- CSS, JavaScript and images --
that comprise the admin's design. To set up a Django admin instance, the first
thing to do is put those media files online somewhere.
To make things easy, Django comes with a pure-Python Web server that builds on
the BaseHTTPServer included in Python's standard library. Let's start the
server and explore the admin site. First, set the ``DJANGO_SETTINGS_MODULE``
environment variable to the location of your admin settings::
(Note: Although Django ships with a default design for its admin site, you can
change it however you'd like. The admin uses Django's own template system and
is powered -- surprise, surprise -- by Django itself, so it is completely
customizable.)
export DJANGO_SETTINGS_MODULE=myproject.settings.admin
The files are in the ``media`` directory of the Django distribution. To
"activate" them, copy that directory under a Web document root somewhere, so
that you can access them via the Web.
Then, run this command to start the server::
Be careful not to put your Python source code under the Web document root. Just
do the media files.
django-admin.py runserver
Then, tell Django where you put them, via ``ADMIN_MEDIA_PREFIX`` in the
``myproject.settings.admin`` settings file. Examples::
It'll start a Web server running locally -- on port 8000, by default. If you
want to change the server's port, pass it as a command-line argument::
# You can leave off the domain if they're on the same domain as your admin
# site will be.
ADMIN_MEDIA_PREFIX = '/adminmedia/'
django-admin.py runserver 8080
# Otherwise, use the fully-qualified domain.
ADMIN_MEDIA_PREFIX = 'http://www.foo.com/adminmedia/'
Make sure to include a trailing slash.
Hook into mod_python
====================
Now let's take the opportunity to hook Django into Apache/mod_python. Edit your
``httpd.conf`` file and add this::
<Location "/admin/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE myproject.settings.admin
PythonDebug On
</Location>
This tells Apache: "Use mod_python for any URL at or under '/admin/', using the
Django mod_python handler." It also passes the value of ``DJANGO_SETTINGS_MODULE``,
so mod_python knows which project to use. Note that we're passing the path to
the ``admin`` settings, not the ``main`` settings. That's because this is the
admin site, which has slightly different settings.
Also, if you've manually altered your ``PYTHONPATH`` to put your project on it,
you'll need to tell mod_python::
PythonPath "['/path/to/project'] + sys.path"
You can also add directives such as ``PythonAutoReload Off`` for performance.
See the `mod_python documentation`_ for a full list of options.
When you've done that, restart Apache and go to /admin/ on your domain. You
should see the admin's login screen:
Now, open a Web browser and go to "/admin/" on your domain. You should see the
admin's login screen:
.. image:: http://media.djangoproject.com/img/doc/tutorial/admin01.png
:alt: Django admin login screen
.. _mod_python documentation: http://modpython.org/live/current/doc-html/directives.html
Create a user account
=====================
We can't log in, though, because we haven't created an admin user account yet.
Drop into the Python interactive interpreter and type this::
You can't log in, though, because you haven't created an admin user account
yet. Drop into the Python interactive interpreter and type this::
# The function django.models.auth.users.create_user() creates a new user
# and returns the new auth.User object.
@ -151,12 +109,9 @@ file and make the following change to add an ``admin`` attribute::
),
)
Reload the Django admin index page. Note that you might have to restart Apache,
depending on your Apache settings. Because mod_python saves code in memory for
performance, Python code changes generally aren't reflected until Apache
restarts. One way around this is to set ``MaxRequestsPerChild 1`` in your
httpd.conf to force Apache to reload everything for each request. But don't do
that on a production server, or we'll revoke your Django privileges.
Restart your development Web server, and reload the Django admin page. You'll
have to restart the server each time you make a change to Python code -- but
we're working on changing that.
Explore the free admin functionality
====================================