Changeset 5639
- Timestamp:
- 07/09/07 21:45:11 (1 year ago)
- Files:
-
- django/trunk/docs/tutorial01.txt (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
django/trunk/docs/tutorial01.txt
r5609 r5639 23 23 24 24 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 26 26 try to help. 27 27 28 .. _django-users: http://groups.google.com/group/django-users 28 .. _django-users: http://groups.google.com/group/django-users 29 29 .. _#django: irc://irc.freenode.net/django 30 30 … … 43 43 44 44 .. note:: 45 45 46 46 You'll need to avoid naming projects after built-in Python or Django 47 47 components. In particular, this means you should avoid using names like … … 322 322 python manage.py sql polls 323 323 324 You should see something similar to the following (the CREATE TABLE SQL statements 324 You should see something similar to the following (the CREATE TABLE SQL statements 325 325 for the polls app):: 326 326 … … 342 342 343 343 * The exact output will vary depending on the database you are using. 344 344 345 345 * Table names are automatically generated by combining the name of the app 346 346 (``polls``) and the lowercase name of the model -- ``poll`` and … … 372 372 373 373 * ``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. 376 376 377 377 * ``python manage.py sqlclear polls`` -- Outputs the necessary ``DROP … … 495 495 .. admonition:: Why ``__unicode__()`` and not ``__str__()``? 496 496 497 If you're familiar with Python, you might be in the habit of adding498 ``__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. 499 499 We use ``__unicode__()`` here because Django models deal with Unicode by 500 500 default. All data stored in your database is converted to Unicode when it's 501 501 returned. 502 502 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. 510 510 511 511 Note these are normal Python methods. Let's add a custom method, just for
