crash-- when loading random quotes when there are no quotes

This commit is contained in:
Trever Fischer
2012-02-18 12:58:58 -05:00
parent 548de830f0
commit d5a4b83a74

View File

@@ -1,5 +1,7 @@
import models
def random_quote(request):
quote = models.Quote.objects.order_by('?')[0]
return {'quote': quote}
quote = models.Quote.objects.order_by('?')
if len(quote) > 0:
return {'quote': quote[0]}
return {}