1
0
mirror of https://github.com/django/django.git synced 2025-10-24 22:26:08 +00:00

Fixed a whole bunch of small docs typos, errors, and ommissions.

Fixes #8358, #8396, #8724, #9043, #9128, #9247, #9267, #9267, #9375, #9409, #9414, #9416, #9446, #9454, #9464, #9503, #9518, #9533, #9657, #9658, #9683, #9733, #9771, #9835, #9836, #9837, #9897, #9906, #9912, #9945, #9986, #9992, #10055, #10084, #10091, #10145, #10245, #10257, #10309, #10358, #10359, #10424, #10426, #10508, #10531, #10551, #10635, #10637, #10656, #10658, #10690, #10699, #19528.

Thanks to all the respective authors of those tickets.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@10371 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Jacob Kaplan-Moss
2009-04-03 18:30:54 +00:00
parent d2a8bc5b40
commit c6c25adf6d
50 changed files with 551 additions and 262 deletions

View File

@@ -134,18 +134,27 @@ It worked!
.. admonition:: Changing the port
By default, the :djadmin:`runserver` command starts the development server
on port 8000. If you want to change the server's port, pass it as a
command-line argument. For instance, this command starts the server on port
8080:
on the internal IP at port 8000.
If you want to change the server's port, pass
it as a command-line argument. For instance, this command starts the server
on port 8080:
.. code-block:: bash
python manage.py runserver 8080
If you want to change the server's IP, pass it along with the port. So to
listen on all public IPs (useful if you want to show off your work on other
computers), use:
.. code-block:: bash
python manage.py runserver 0.0.0.0:8000
Full docs for the development server can be found in the
:djadmin:`runserver` reference.
Database setup
--------------

View File

@@ -302,6 +302,13 @@ for a given poll. Here's the view::
The new concept here: The view raises the :exc:`~django.http.Http404` exception
if a poll with the requested ID doesn't exist.
We'll discuss what you could put in that ``polls/detail.html`` template a bit
later, but if you'd like to quickly get the above example working, just::
{{ poll }}
will get you started for now.
A shortcut: get_object_or_404()
-------------------------------
@@ -357,6 +364,10 @@ in ``django/conf/urls/defaults.py``, ``handler404`` is set to
Three more things to note about 404 views:
* If :setting:`DEBUG` is set to ``True`` (in your settings module) then your
404 view will never be used (and thus the ``404.html`` template will never
be rendered) because the traceback will be displayed instead.
* The 404 view is also called if Django doesn't find a match after checking
every regular expression in the URLconf.
@@ -365,8 +376,9 @@ Three more things to note about 404 views:
template in the root of your template directory. The default 404 view will
use that template for all 404 errors.
* If :setting:`DEBUG` is set to ``True`` (in your settings module) then your
404 view will never be used, and the traceback will be displayed instead.
* If :setting:`DEBUG` is set to ``False`` (in your settings module) and if
you didn't create a ``404.html`` file, an ``Http500`` is raised instead.
So remember to create a ``404.html``.
Write a 500 (server error) view
===============================

View File

@@ -20,7 +20,7 @@ tutorial, so that the template contains an HTML ``<form>`` element:
{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}
<form action="/polls/{{ poll.id }}/vote/" method="post">
<form action="vote/" method="post">
{% for choice in poll.choice_set.all %}
<input type="radio" name="choice" id="choice{{ forloop.counter }}" value="{{ choice.id }}" />
<label for="choice{{ forloop.counter }}">{{ choice.choice }}</label><br />
@@ -36,12 +36,12 @@ A quick rundown:
selects one of the radio buttons and submits the form, it'll send the
POST data ``choice=3``. This is HTML Forms 101.
* We set the form's ``action`` to ``/polls/{{ poll.id }}/vote/``, and we
set ``method="post"``. Using ``method="post"`` (as opposed to
``method="get"``) is very important, because the act of submitting this
form will alter data server-side. Whenever you create a form that alters
data server-side, use ``method="post"``. This tip isn't specific to
Django; it's just good Web development practice.
* We set the form's ``action`` to ``vote/``, and we set ``method="post"``.
Using ``method="post"`` (as opposed to ``method="get"``) is very
important, because the act of submitting this form will alter data
server-side. Whenever you create a form that alters data server-side, use
``method="post"``. This tip isn't specific to Django; it's just good Web
development practice.
* ``forloop.counter`` indicates how many times the :ttag:`for` tag has gone
through its loop
@@ -170,7 +170,17 @@ to write Python code to write an app.
Let's convert our poll app to use the generic views system, so we can delete a
bunch of our own code. We'll just have to take a few steps to make the
conversion.
conversion. We will:
1. Convert the URLconf.
2. Rename a few templates.
3. Delete some the old, now unneeded views.
4. Fix up URL handling for the new views.
Read on for details.
.. admonition:: Why the code-shuffle?