From a8572b18a9a2bb2b73950ce078f7c3aae9e8e5af Mon Sep 17 00:00:00 2001 From: Adrian Holovaty Date: Sun, 30 Apr 2006 03:42:53 +0000 Subject: magic-removal: Replaced __repr__() with __str__() in docs git-svn-id: http://code.djangoproject.com/svn/django/branches/magic-removal@2795 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- docs/tutorial01.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'docs/tutorial01.txt') diff --git a/docs/tutorial01.txt b/docs/tutorial01.txt index 8ce9f6539d..02d2795261 100644 --- a/docs/tutorial01.txt +++ b/docs/tutorial01.txt @@ -456,20 +456,20 @@ Once you're in the shell, explore the database API:: Wait a minute. ```` 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 ``__repr__()`` method to +(in the ``polls/models.py`` file) and adding a ``__str__()`` method to both ``Poll`` and ``Choice``:: class Poll(models.Model): # ... - def __repr__(self): + def __str__(self): return self.question class Choice(models.Model): # ... - def __repr__(self): + def __str__(self): return self.choice -It's important to add ``__repr__()`` methods to your models, not only for your +It's important to add ``__str__()`` 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. @@ -491,7 +491,7 @@ Let's jump back into the Python interactive shell by running >>> from mysite.polls.models import Poll, Choice - # Make sure our __repr__() addition worked. + # Make sure our __str__() addition worked. >>> Poll.objects.all() [What's up?] -- cgit v1.3