diff --git a/tipp/views.py b/tipp/views.py index 7fe0ee2..3c2319a 100644 --- a/tipp/views.py +++ b/tipp/views.py @@ -30,7 +30,7 @@ from django.core.urlresolvers import reverse from django.core.paginator import Paginator, InvalidPage, EmptyPage, PageNotAnInteger from django.utils import timezone from django.utils.text import slugify -from django.db.models import Sum +from django.db.models import Sum, Max from django.conf import settings from os.path import join as pjoin from tipp.models import * @@ -414,7 +414,6 @@ def charts(request, ls, season, pos='default', template_name='charts.html'): 'pos': pos }) - @login_required def blogindex(request, page): # get the blog posts that are published @@ -496,7 +495,13 @@ def logout(request): def get_current_md(ls,season): """ get current matchday """ - current_md = Match.objects.filter(leagueShortcut=ls, season=season, finished=False).order_by('matchday').values_list('matchday', flat=True).distinct()[0] + try: + current_md = Match.objects.filter(leagueShortcut=ls, season=season, \ + finished=False).order_by('matchday').values_list('matchday', \ + flat=True).distinct()[0] + except IndexError: + current_md = Match.objects.filter(leagueShortcut=ls, season=season).aggregate(Max('matchday')) + return(current_md) def get_current_ls():