summaryrefslogtreecommitdiff
path: root/docs/intro/tutorial01.txt
diff options
context:
space:
mode:
Diffstat (limited to 'docs/intro/tutorial01.txt')
-rw-r--r--docs/intro/tutorial01.txt35
1 files changed, 19 insertions, 16 deletions
diff --git a/docs/intro/tutorial01.txt b/docs/intro/tutorial01.txt
index 7f69945300..d623bd8451 100644
--- a/docs/intro/tutorial01.txt
+++ b/docs/intro/tutorial01.txt
@@ -23,7 +23,8 @@ If Django is installed, you should see the version of your installation. If it
isn't, you'll get an error telling "No module named django".
This tutorial is written for Django |version| and Python 2.x. If the Django
-version doesn't match, you can refer to the tutorial for your version of Django
+version doesn't match, you can refer to the tutorial for your version of
+Django by using the version switcher at the bottom right corner of this page,
or update Django to the newest version. If you are using Python 3.x, be aware
that your code may need to differ from what is in the tutorial and you should
continue using the tutorial only if you know what you are doing with Python
@@ -122,7 +123,7 @@ These files are:
"table of contents" of your Django-powered site. You can read more about
URLs in :doc:`/topics/http/urls`.
-* :file:`mysite/wsgi.py`: An entry-point for WSGI-compatible webservers to
+* :file:`mysite/wsgi.py`: An entry-point for WSGI-compatible web servers to
serve your project. See :doc:`/howto/deployment/wsgi/index` for more details.
.. _more about packages: http://docs.python.org/tutorial/modules.html#packages
@@ -242,9 +243,6 @@ come with Django:
* :mod:`django.contrib.sessions` -- A session framework.
-* :mod:`django.contrib.sites` -- A framework for managing multiple sites
- with one Django installation.
-
* :mod:`django.contrib.messages` -- A messaging framework.
* :mod:`django.contrib.staticfiles` -- A framework for managing
@@ -252,7 +250,7 @@ come with Django:
These applications are included by default as a convenience for the common case.
-Each of these applications makes use of at least one database table, though,
+Some of these applications makes use of at least one database table, though,
so we need to create the tables in the database before we can use them. To do
that, run the following command:
@@ -581,27 +579,32 @@ Wait a minute. ``<Poll: Poll object>`` is, utterly, an unhelpful representation
of this object. Let's fix that by editing the polls model (in the
``polls/models.py`` file) and adding a
:meth:`~django.db.models.Model.__unicode__` method to both ``Poll`` and
-``Choice``::
+``Choice``. On Python 3, simply replace ``__unicode__`` by ``__str__`` in the
+following example::
class Poll(models.Model):
# ...
- def __unicode__(self):
+ def __unicode__(self): # Python 3: def __str__(self):
return self.question
class Choice(models.Model):
# ...
- def __unicode__(self):
+ def __unicode__(self): # Python 3: def __str__(self):
return self.choice_text
-It's important to add :meth:`~django.db.models.Model.__unicode__` methods to
-your models, not only for your own sanity when dealing with the interactive
-prompt, but also because objects' representations are used throughout Django's
-automatically-generated admin.
+It's important to add :meth:`~django.db.models.Model.__unicode__` methods (or
+:meth:`~django.db.models.Model.__str__` on Python 3) to your models, not only
+for your own sanity when dealing with the interactive prompt, but also because
+objects' representations are used throughout Django's automatically-generated
+admin.
+
+.. admonition:: `__unicode__` or `__str__`?
-.. admonition:: Why :meth:`~django.db.models.Model.__unicode__` and not
- :meth:`~django.db.models.Model.__str__`?
+ On Python 3, things are simpler, just use
+ :meth:`~django.db.models.Model.__str__` and forget about
+ :meth:`~django.db.models.Model.__unicode__`.
- If you're familiar with Python, you might be in the habit of adding
+ If you're familiar with Python 2, you might be in the habit of adding
:meth:`~django.db.models.Model.__str__` methods to your classes, not
:meth:`~django.db.models.Model.__unicode__` methods. We use
:meth:`~django.db.models.Model.__unicode__` here because Django models deal