Avoid PostTracking.DoesNotExist exception when no Posts exist.
This happens on a fresh install when a users clicks on "Show new posts since last visit".
This commit is contained in:
parent
2acc7b1ee9
commit
1d2eb6ce38
1 changed files with 4 additions and 1 deletions
|
@ -118,7 +118,10 @@ def search(request):
|
|||
date = datetime.today() - timedelta(1)
|
||||
topics = topics.filter(created__gte=date)
|
||||
elif action == 'show_new':
|
||||
last_read = PostTracking.objects.get(user=request.user).last_read
|
||||
try:
|
||||
last_read = PostTracking.objects.get(user=request.user).last_read
|
||||
except PostTracking.DoesNotExist:
|
||||
last_read = None
|
||||
if last_read:
|
||||
topics = topics.filter(last_post__updated__gte=last_read).all()
|
||||
else:
|
||||
|
|
Reference in a new issue