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:
parent
62cc287b2b
commit
b55b29c891
56
docs/faq.txt
56
docs/faq.txt
|
@ -21,7 +21,6 @@ able to give something back to the open-source community.
|
||||||
.. _Python: http://www.python.org/
|
.. _Python: http://www.python.org/
|
||||||
.. _PostgreSQL: http://www.postgresql.org/
|
.. _PostgreSQL: http://www.postgresql.org/
|
||||||
|
|
||||||
|
|
||||||
What does "Django" mean, and how do you pronounce it?
|
What does "Django" mean, and how do you pronounce it?
|
||||||
-----------------------------------------------------
|
-----------------------------------------------------
|
||||||
|
|
||||||
|
@ -97,8 +96,8 @@ Lawrence, Kansas, USA.
|
||||||
Django appears to be a MVC framework, but you call the Controller the "view", and the View the "template". How come you don't use the standard names?
|
Django appears to be a MVC framework, but you call the Controller the "view", and the View the "template". How come you don't use the standard names?
|
||||||
-----------------------------------------------------------------------------------------------------------------------------------------------------
|
-----------------------------------------------------------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
That's because Django isn't strictly a MVC framework. We don't really believe in
|
That's because Django isn't strictly a MVC framework. We don't really believe in
|
||||||
any capital-M Methodologies; we do what "feels" right. If you squint the right
|
any capital-M Methodologies; we do what "feels" right. If you squint the right
|
||||||
way, you can call Django's ORM the "Model", the view functions the "View", and
|
way, you can call Django's ORM the "Model", the view functions the "View", and
|
||||||
the dynamically-generated API the "Controller" -- but not really.
|
the dynamically-generated API the "Controller" -- but not really.
|
||||||
|
|
||||||
|
@ -109,7 +108,7 @@ where it makes sense.
|
||||||
Do you have any of those nifty "screencast" things?
|
Do you have any of those nifty "screencast" things?
|
||||||
---------------------------------------------------
|
---------------------------------------------------
|
||||||
|
|
||||||
They're in the works. It's amazing how much time those things take! Stay tuned...
|
They're in the works. It's amazing how much time those things take! Stay tuned...
|
||||||
|
|
||||||
Installation questions
|
Installation questions
|
||||||
======================
|
======================
|
||||||
|
@ -120,13 +119,14 @@ How do I get started?
|
||||||
#. `Download the code`_.
|
#. `Download the code`_.
|
||||||
#. Install Django (read the `installation guide`_).
|
#. Install Django (read the `installation guide`_).
|
||||||
#. Walk through the tutorial_.
|
#. 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.
|
run into trouble.
|
||||||
|
|
||||||
.. _`Download the code`: http://www.djangoproject.com/download/
|
.. _`Download the code`: http://www.djangoproject.com/download/
|
||||||
.. _`installation guide`: http://www.djangoproject.com/documentation/install/
|
.. _`installation guide`: http://www.djangoproject.com/documentation/install/
|
||||||
.. _tutorial: http://www.djangoproject.com/documentation/tutorial1/
|
.. _tutorial: http://www.djangoproject.com/documentation/tutorial1/
|
||||||
.. _documentation: http://www.djangoproject.com/documentation/
|
.. _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?
|
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?
|
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
|
You'll also need a database engine. PostgreSQL_ is recommended, and MySQL_ is
|
||||||
supported.
|
supported.
|
||||||
|
@ -144,18 +150,32 @@ supported.
|
||||||
.. _Python: http://www.python.org/
|
.. _Python: http://www.python.org/
|
||||||
.. _Apache 2: http://httpd.apache.org/
|
.. _Apache 2: http://httpd.apache.org/
|
||||||
.. _mod_python: http://www.modpython.org/
|
.. _mod_python: http://www.modpython.org/
|
||||||
|
.. _WSGI: http://www.python.org/peps/pep-0333.html
|
||||||
.. _PostgreSQL: http://www.postgresql.org/
|
.. _PostgreSQL: http://www.postgresql.org/
|
||||||
.. _MySQL: http://www.mysql.com/
|
.. _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?
|
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.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
|
||||||
* For Python 2.3, grab mod_python from http://www.mod_python.org/, the read
|
`Running mod_python on Apache on Windows2000`_.
|
||||||
`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
|
.. _`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
|
.. _`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.)
|
(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)?
|
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
|
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
|
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.
|
the admin`_ to get you started.
|
||||||
|
|
||||||
.. _`guide to the CSS used in the admin`: http://www.djangoproject.com/documentation/admin_css/
|
.. _`guide to the CSS used in the admin`: http://www.djangoproject.com/documentation/admin_css/
|
||||||
|
|
||||||
|
|
|
@ -7,16 +7,20 @@ This document will get you up and running with Django.
|
||||||
Install Apache and mod_python
|
Install Apache and mod_python
|
||||||
=============================
|
=============================
|
||||||
|
|
||||||
Currently, Django runs on Apache_ with `mod_python`_. mod_python is similar to
|
If you just want to experiment with Django, skip this step. Django comes with
|
||||||
mod_perl -- it embeds Python within Apache and loads Python code into memory
|
its own Web server for development purposes.
|
||||||
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 can't use mod_python for some reason, fear not: We're planning full WSGI_
|
If you want to use Django on a production site, use Apache with `mod_python`_.
|
||||||
support, which means Django will run on a variety of server platforms.
|
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
|
If you can't use mod_python for some reason, fear not: Django follows the WSGI_
|
||||||
module activated.
|
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/
|
.. _Apache: http://httpd.apache.org/
|
||||||
.. _mod_python: http://www.modpython.org/
|
.. _mod_python: http://www.modpython.org/
|
||||||
|
|
|
@ -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
|
The admin isn't necessarily intended to be used by site visitors; it's for site
|
||||||
managers.
|
managers.
|
||||||
|
|
||||||
Expose the admin media files
|
Start the development server
|
||||||
============================
|
============================
|
||||||
|
|
||||||
Django's admin is intended to be fully functional and good looking. For that
|
To make things easy, Django comes with a pure-Python Web server that builds on
|
||||||
reason, Django ships with admin media files -- CSS, JavaScript and images --
|
the BaseHTTPServer included in Python's standard library. Let's start the
|
||||||
that comprise the admin's design. To set up a Django admin instance, the first
|
server and explore the admin site. First, set the ``DJANGO_SETTINGS_MODULE``
|
||||||
thing to do is put those media files online somewhere.
|
environment variable to the location of your admin settings::
|
||||||
|
|
||||||
(Note: Although Django ships with a default design for its admin site, you can
|
export DJANGO_SETTINGS_MODULE=myproject.settings.admin
|
||||||
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.)
|
|
||||||
|
|
||||||
The files are in the ``media`` directory of the Django distribution. To
|
Then, run this command to start the server::
|
||||||
"activate" them, copy that directory under a Web document root somewhere, so
|
|
||||||
that you can access them via the Web.
|
|
||||||
|
|
||||||
Be careful not to put your Python source code under the Web document root. Just
|
django-admin.py runserver
|
||||||
do the media files.
|
|
||||||
|
|
||||||
Then, tell Django where you put them, via ``ADMIN_MEDIA_PREFIX`` in the
|
It'll start a Web server running locally -- on port 8000, by default. If you
|
||||||
``myproject.settings.admin`` settings file. Examples::
|
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
|
django-admin.py runserver 8080
|
||||||
# site will be.
|
|
||||||
ADMIN_MEDIA_PREFIX = '/adminmedia/'
|
|
||||||
|
|
||||||
# Otherwise, use the fully-qualified domain.
|
Now, open a Web browser and go to "/admin/" on your domain. You should see the
|
||||||
ADMIN_MEDIA_PREFIX = 'http://www.foo.com/adminmedia/'
|
admin's login screen:
|
||||||
|
|
||||||
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:
|
|
||||||
|
|
||||||
.. image:: http://media.djangoproject.com/img/doc/tutorial/admin01.png
|
.. image:: http://media.djangoproject.com/img/doc/tutorial/admin01.png
|
||||||
:alt: Django admin login screen
|
:alt: Django admin login screen
|
||||||
|
|
||||||
.. _mod_python documentation: http://modpython.org/live/current/doc-html/directives.html
|
|
||||||
|
|
||||||
Create a user account
|
Create a user account
|
||||||
=====================
|
=====================
|
||||||
|
|
||||||
We can't log in, though, because we haven't created an admin user account yet.
|
You can't log in, though, because you haven't created an admin user account
|
||||||
Drop into the Python interactive interpreter and type this::
|
yet. Drop into the Python interactive interpreter and type this::
|
||||||
|
|
||||||
# The function django.models.auth.users.create_user() creates a new user
|
# The function django.models.auth.users.create_user() creates a new user
|
||||||
# and returns the new auth.User object.
|
# 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,
|
Restart your development Web server, and reload the Django admin page. You'll
|
||||||
depending on your Apache settings. Because mod_python saves code in memory for
|
have to restart the server each time you make a change to Python code -- but
|
||||||
performance, Python code changes generally aren't reflected until Apache
|
we're working on changing that.
|
||||||
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.
|
|
||||||
|
|
||||||
Explore the free admin functionality
|
Explore the free admin functionality
|
||||||
====================================
|
====================================
|
||||||
|
|
Loading…
Reference in New Issue