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
This commit is contained in:
Malcolm Tredinnick 2007-05-11 09:44:13 +00:00
parent ee227a8507
commit 7c0ef82752
1 changed files with 5 additions and 2 deletions

View File

@ -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)