mirror of
https://github.com/django/django.git
synced 2025-10-31 09:41:08 +00:00
Fixed #27587 -- Adding examples of QuerySet.query.__str__() to docs.
This commit is contained in:
@@ -473,8 +473,14 @@ Save these changes and start a new Python interactive shell by running
|
||||
>>> from polls.models import Choice, Question
|
||||
|
||||
# Make sure our __str__() addition worked.
|
||||
>>> Question.objects.all()
|
||||
>>> q = Question.objects.all()
|
||||
>>> q
|
||||
<QuerySet [<Question: What's up?>]>
|
||||
# Print the SQL used to query the database
|
||||
>>> from pprint import pprint
|
||||
>>> pprint(str(q.query))
|
||||
('SELECT "polls_question"."id", "polls_question"."question_text", '
|
||||
'"polls_question"."pub_date" FROM "polls_question"')
|
||||
|
||||
# Django provides a rich database lookup API that's entirely driven by
|
||||
# keyword arguments.
|
||||
|
||||
Reference in New Issue
Block a user