From 7c0ef82752bd24dcce8113312b539a637b760061 Mon Sep 17 00:00:00 2001 From: Malcolm Tredinnick Date: Fri, 11 May 2007 09:44:13 +0000 Subject: [PATCH] Fixed #4276 -- Fixed a crash in the lorem tag when more than 20 words were requested. git-svn-id: http://code.djangoproject.com/svn/django/trunk@5190 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/contrib/webdesign/lorem_ipsum.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/django/contrib/webdesign/lorem_ipsum.py b/django/contrib/webdesign/lorem_ipsum.py index 70baa805df..6226bbef1b 100644 --- a/django/contrib/webdesign/lorem_ipsum.py +++ b/django/contrib/webdesign/lorem_ipsum.py @@ -59,8 +59,11 @@ def words(count, common=True): word_list = [] c = len(word_list) if count > c: - count = min(count - c, len(WORDS)) - word_list += random.sample(WORDS, count - c) + count -= c + while count > 0: + c = min(count, len(WORDS)) + count -= c + word_list += random.sample(WORDS, c) else: word_list = word_list[:count] return ' '.join(word_list)