summaryrefslogtreecommitdiff
path: root/docs/tutorial02.txt
diff options
context:
space:
mode:
authorAdrian Holovaty <adrian@holovaty.com>2006-01-11 05:07:38 +0000
committerAdrian Holovaty <adrian@holovaty.com>2006-01-11 05:07:38 +0000
commit8013f76a40270283f9d3c04160ac9b8a72ffe2be (patch)
tree7b7626286b882c3622d341ab6d1e56c4e0083607 /docs/tutorial02.txt
parent8f42a9246580dc11e8c1975eb364816495ba488c (diff)
magic-removal: Merged to [1903]
git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@1904 bcc190cf-cafb-0310-a4f2-bffc1f526a37
Diffstat (limited to 'docs/tutorial02.txt')
-rw-r--r--docs/tutorial02.txt45
1 files changed, 19 insertions, 26 deletions
diff --git a/docs/tutorial02.txt b/docs/tutorial02.txt
index 21454523d0..c7a38f8a01 100644
--- a/docs/tutorial02.txt
+++ b/docs/tutorial02.txt
@@ -31,7 +31,7 @@ The Django admin site is not activated by default -- it's an opt-in thing. To
activate the admin site for your installation, do these three things:
* Add ``"django.contrib.admin"`` to your ``INSTALLED_APPS`` setting.
- * Run the command ``django-admin.py install admin``. This will create an
+ * Run the command ``python manage.py install admin``. This will create an
extra database table that the admin needs.
* Edit your ``myproject/urls.py`` file and uncomment the line below
"Uncomment this for admin:". This file is a URLconf; we'll dig into
@@ -43,28 +43,18 @@ Create a user account
Run the following command to create a superuser account for your admin site::
- django-admin.py createsuperuser --settings=myproject.settings
+ python manage.py createsuperuser
The script will prompt you for a username, e-mail address and password (twice).
Start the development server
============================
-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.
+Let's start the development server and explore the admin site.
-Just run the following command to start the server::
+Recall from Tutorial 1 that you start the development server like so::
- django-admin.py runserver --settings=myproject.settings
-
-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::
-
- django-admin.py runserver 8080 --settings=myproject.settings
-
-DON'T use this server in anything resembling a production environment. It's
-intended only for use while developing.
+ python manage.py runserver
Now, open a Web browser and go to "/admin/" on your local domain -- e.g.,
http://127.0.0.1:8000/admin/. You should see the admin's login screen:
@@ -91,8 +81,8 @@ Make the poll app modifiable in the admin
But where's our poll app? It's not displayed on the admin index page.
-Just one thing to do: We need to specify in the ``polls.Poll`` model that Poll
-objects have an admin interface. Edit the ``myproject/apps/polls/models/polls.py``
+Just one thing to do: We need to specify in the ``Poll`` model that ``Poll``
+objects have an admin interface. Edit the ``myproject/polls/models/polls.py``
file and make the following change to add an inner ``Meta`` class with an
``admin`` attribute::
@@ -101,11 +91,13 @@ file and make the following change to add an inner ``Meta`` class with an
class Meta:
admin = meta.Admin()
-The ``class Meta`` contains all non-field metadata about this model.
+The ``class Meta`` contains all `non-field metadata`_ about this model.
Now reload the Django admin page to see your changes. Note that you don't have
to restart the development server -- it auto-reloads code.
+.. _non-field metadata: http://www.djangoproject.com/documentation/model_api/#meta-options
+
Explore the free admin functionality
====================================
@@ -216,14 +208,14 @@ aren't commonly used::
Adding related objects
======================
-OK, we have our Poll admin page. But a ``Poll`` has multiple ``Choices``, and the admin
-page doesn't display choices.
+OK, we have our Poll admin page. But a ``Poll`` has multiple ``Choices``, and
+the admin page doesn't display choices.
Yet.
-In this case, there are two ways to solve this problem. The first is to give
-the ``Choice`` model its own ``admin`` attribute, just as we did with ``Poll``.
-Here's what that would look like::
+There are two ways to solve this problem. The first is to give the ``Choice``
+model its own ``admin`` attribute, just as we did with ``Poll``. Here's what
+that would look like::
class Choice(meta.Model):
# ...
@@ -237,7 +229,8 @@ looks like this:
:alt: Choice admin page
In that form, the "Poll" field is a select box containing every poll in the
-database. In our case, only one poll exists at this point.
+database. Django knows that a ``ForeignKey`` should be represented in the admin
+as a ``<select>`` box. In our case, only one poll exists at this point.
Also note the "Add Another" link next to "Poll." Every object with a ForeignKey
relationship to another gets this for free. When you click "Add Another," you'll
@@ -363,7 +356,7 @@ This is shaping up well. Let's add some search capability::
That adds a search box at the top of the change list. When somebody enters
search terms, Django will search the ``question`` field. You can use as many
-fields as you'd like -- although because it uses a LIKE query behind the
+fields as you'd like -- although because it uses a ``LIKE`` query behind the
scenes, keep it reasonable, to keep your database happy.
Finally, because Poll objects have dates, it'd be convenient to be able to
@@ -444,7 +437,7 @@ hard-code links to object-specific admin pages in whatever way you think is
best.
Django offers another shortcut in this department. Run the command
-``django-admin.py adminindex polls`` to get a chunk of template code for
+``python manage.py adminindex polls`` to get a chunk of template code for
inclusion in the admin index template. It's a useful starting point.
For full details on customizing the look and feel of the Django admin site in