Permalink
Browse files

Catch the no-user case when checking site age.

  • Loading branch information...
1 parent 75f5469 commit abc23d60bbe34e46b3f9ee6737d91ba8c84c1cec @melinath melinath committed Jul 13, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 localtv/management/__init__.py
@@ -25,8 +25,13 @@
def site_too_old():
- if User.objects.order_by('-last_login').values_list(
- 'last_login', flat=True)[0] + TWO_MONTHS < datetime.datetime.now():
+ try:
+ last_login = User.objects.order_by('-last_login').values_list(
+ 'last_login', flat=True)[0]
+ except IndexError:
+ # Always too old if there are no users.
+ return True
+ if last_login + TWO_MONTHS < datetime.datetime.now():
return True
else:
return False

0 comments on commit abc23d6

Please sign in to comment.