mirror of
https://github.com/django/django.git
synced 2025-10-23 21:59:11 +00:00
Fixed #27953 -- Added instance's pk to Model.__str__().
This commit is contained in:
committed by
Tim Graham
parent
7c9cb1ed37
commit
1a49b89470
@@ -437,11 +437,11 @@ Once you're in the shell, explore the :doc:`database API </topics/db/queries>`::
|
||||
|
||||
# objects.all() displays all the questions in the database.
|
||||
>>> Question.objects.all()
|
||||
<QuerySet [<Question: Question object>]>
|
||||
<QuerySet [<Question: Question object (1)>]>
|
||||
|
||||
Wait a minute. ``<Question: Question object>`` is, utterly, an unhelpful representation
|
||||
of this object. Let's fix that by editing the ``Question`` model (in the
|
||||
``polls/models.py`` file) and adding a
|
||||
Wait a minute. ``<Question: Question object (1)>`` isn't a helpful
|
||||
representation of this object. Let's fix that by editing the ``Question`` model
|
||||
(in the ``polls/models.py`` file) and adding a
|
||||
:meth:`~django.db.models.Model.__str__` method to both ``Question`` and
|
||||
``Choice``:
|
||||
|
||||
|
||||
Reference in New Issue
Block a user