1
0
mirror of https://github.com/django/django.git synced 2025-10-24 06:06:09 +00:00

[1.0.X] Fixed #6748 -- When printing the repr() of querysets, don't load or

display more than 20 objects.

This means that accidentally executing HugeStoryArchive.objects.all() at the
interactive prompt (or in the debug template) won't try to load all 4,233,010
stories into memory and print them out. That would previously cause resource
starvation and other "interesting" crashes.

If you really, really want the previous behaviour (e.g. in a doctest that
prints more than 20 items), display "list(qs)" instead of just "qs".

Backport of r9202 from trunk.


git-svn-id: http://code.djangoproject.com/svn/django/branches/releases/1.0.X@9205 bcc190cf-cafb-0310-a4f2-bffc1f526a37
This commit is contained in:
Malcolm Tredinnick
2008-10-08 08:44:17 +00:00
parent 09d84c4d40
commit 4b687d01ba
2 changed files with 8 additions and 2 deletions

View File

@@ -556,7 +556,7 @@ Bug #2076
# automatically. Item normally requires a join with Note to do the default
# ordering, but that isn't needed here.
>>> qs = Item.objects.order_by('name')
>>> qs
>>> list(qs)
[<Item: four>, <Item: one>, <Item: three>, <Item: two>]
>>> len(qs.query.tables)
1