Fixed #4814 -- Fixed some whitespace issues in tutorial01, thanks John Shaffer.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@5639 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Gary Wilson Jr 2007-07-10 02:45:11 +00:00
parent 0be6d32c24
commit 541c9ff797
1 changed files with 15 additions and 15 deletions

View File

@ -22,10 +22,10 @@ installed.
.. admonition:: Where to get help: .. admonition:: Where to get help:
If you're having trouble going through this tutorial, please post a message If you're having trouble going through this tutorial, please post a message
to `django-users`_ or drop by `#django`_ on ``irc.freenode.net`` and we'll to `django-users`_ or drop by `#django`_ on ``irc.freenode.net`` and we'll
try to help. try to help.
.. _django-users: http://groups.google.com/group/django-users .. _django-users: http://groups.google.com/group/django-users
.. _#django: irc://irc.freenode.net/django .. _#django: irc://irc.freenode.net/django
Creating a project Creating a project
@ -42,7 +42,7 @@ code, then run the command ``django-admin.py startproject mysite``. This
will create a ``mysite`` directory in your current directory. will create a ``mysite`` directory in your current directory.
.. note:: .. note::
You'll need to avoid naming projects after built-in Python or Django You'll need to avoid naming projects after built-in Python or Django
components. In particular, this means you should avoid using names like components. In particular, this means you should avoid using names like
``django`` (which will conflict with Django itself) or ``site`` (which ``django`` (which will conflict with Django itself) or ``site`` (which
@ -321,7 +321,7 @@ Now Django knows ``mysite`` includes the ``polls`` app. Let's run another comman
python manage.py sql polls python manage.py sql polls
You should see something similar to the following (the CREATE TABLE SQL statements You should see something similar to the following (the CREATE TABLE SQL statements
for the polls app):: for the polls app)::
BEGIN; BEGIN;
@ -341,7 +341,7 @@ for the polls app)::
Note the following: Note the following:
* The exact output will vary depending on the database you are using. * The exact output will vary depending on the database you are using.
* Table names are automatically generated by combining the name of the app * Table names are automatically generated by combining the name of the app
(``polls``) and the lowercase name of the model -- ``poll`` and (``polls``) and the lowercase name of the model -- ``poll`` and
``choice``. (You can override this behavior.) ``choice``. (You can override this behavior.)
@ -371,8 +371,8 @@ If you're interested, also run the following commands:
construction of your models. construction of your models.
* ``python manage.py sqlcustom polls`` -- Outputs any custom SQL statements * ``python manage.py sqlcustom polls`` -- Outputs any custom SQL statements
(such as table modifications or constraints) that are defined for the (such as table modifications or constraints) that are defined for the
application. application.
* ``python manage.py sqlclear polls`` -- Outputs the necessary ``DROP * ``python manage.py sqlclear polls`` -- Outputs the necessary ``DROP
TABLE`` statements for this app, according to which tables already exist TABLE`` statements for this app, according to which tables already exist
@ -494,19 +494,19 @@ admin.
.. admonition:: Why ``__unicode__()`` and not ``__str__()``? .. admonition:: Why ``__unicode__()`` and not ``__str__()``?
If you're familiar with Python, you might be in the habit of adding If you're familiar with Python, you might be in the habit of adding
``__str__()`` methods to your classes, not ``__unicode__()`` methods. ``__str__()`` methods to your classes, not ``__unicode__()`` methods.
We use ``__unicode__()`` here because Django models deal with Unicode by We use ``__unicode__()`` here because Django models deal with Unicode by
default. All data stored in your database is converted to Unicode when it's default. All data stored in your database is converted to Unicode when it's
returned. returned.
Django models have a default ``__str__()`` method that calls ``__unicode__()`` Django models have a default ``__str__()`` method that calls
and converts the result to a UTF-8 bytestring. This means that ``unicode(p)`` ``__unicode__()`` and converts the result to a UTF-8 bytestring. This means
will return a Unicode string, and ``str(p)`` will return a normal string, that ``unicode(p)`` will return a Unicode string, and ``str(p)`` will return
with characters encoded as UTF-8. a normal string, with characters encoded as UTF-8.
If all of this is jibberish to you, just remember to add ``__unicode__()`` If all of this is jibberish to you, just remember to add ``__unicode__()``
methods to your models. With any luck, things should Just Work for you. methods to your models. With any luck, things should Just Work for you.
Note these are normal Python methods. Let's add a custom method, just for Note these are normal Python methods. Let's add a custom method, just for
demonstration:: demonstration::