Django

Code

Changeset 5639

Show
Ignore:
Timestamp:
07/09/07 21:45:11 (1 year ago)
Author:
gwilson
Message:

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

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • django/trunk/docs/tutorial01.txt

    r5609 r5639  
    2323 
    2424    If you're having trouble going through this tutorial, please post a message 
    25     to `django-users`_ or drop by `#django`_ on ``irc.freenode.net`` and we'll  
     25    to `django-users`_ or drop by `#django`_ on ``irc.freenode.net`` and we'll 
    2626    try to help. 
    2727 
    28 .. _django-users: http://groups.google.com/group/django-users  
     28.. _django-users: http://groups.google.com/group/django-users 
    2929.. _#django: irc://irc.freenode.net/django 
    3030 
     
    4343 
    4444.. note:: 
    45      
     45 
    4646    You'll need to avoid naming projects after built-in Python or Django 
    4747    components. In particular, this means you should avoid using names like 
     
    322322    python manage.py sql polls 
    323323 
    324 You should see something similar to the following (the CREATE TABLE SQL statements  
     324You should see something similar to the following (the CREATE TABLE SQL statements 
    325325for the polls app):: 
    326326 
     
    342342 
    343343    * The exact output will vary depending on the database you are using. 
    344      
     344 
    345345    * Table names are automatically generated by combining the name of the app 
    346346      (``polls``) and the lowercase name of the model -- ``poll`` and 
     
    372372 
    373373    * ``python manage.py sqlcustom polls`` -- Outputs any custom SQL statements 
    374       (such as table modifications or constraints) that are defined for the  
    375       application.  
     374      (such as table modifications or constraints) that are defined for the 
     375      application. 
    376376 
    377377    * ``python manage.py sqlclear polls`` -- Outputs the necessary ``DROP 
     
    495495.. admonition:: Why ``__unicode__()`` and not ``__str__()``? 
    496496 
    497        If you're familiar with Python, you might be in the habit of adding 
    498        ``__str__()`` methods to your classes, not ``__unicode__()`` methods. 
     497    If you're familiar with Python, you might be in the habit of adding 
     498    ``__str__()`` methods to your classes, not ``__unicode__()`` methods. 
    499499    We use ``__unicode__()`` here because Django models deal with Unicode by 
    500500    default. All data stored in your database is converted to Unicode when it's 
    501501    returned. 
    502502 
    503         Django models have a default ``__str__()`` method that calls ``__unicode__()`` 
    504         and converts the result to a UTF-8 bytestring. This means that ``unicode(p)`` 
    505         will return a Unicode string, and ``str(p)`` will return a normal string, 
    506        with characters encoded as UTF-8. 
    507  
    508        If all of this is jibberish to you, just remember to add ``__unicode__()`` 
    509        methods to your models. With any luck, things should Just Work for you. 
     503    Django models have a default ``__str__()`` method that calls 
     504    ``__unicode__()`` and converts the result to a UTF-8 bytestring. This means 
     505    that ``unicode(p)`` will return a Unicode string, and ``str(p)`` will return 
     506    a normal string, with characters encoded as UTF-8. 
     507 
     508    If all of this is jibberish to you, just remember to add ``__unicode__()`` 
     509    methods to your models. With any luck, things should Just Work for you. 
    510510 
    511511Note these are normal Python methods. Let's add a custom method, just for