Skip to content

Commit

Permalink
fixed duplicates in recent view
Browse files Browse the repository at this point in the history
  • Loading branch information
vabene1111 committed May 27, 2020
1 parent 744fbc7 commit dfb1d80
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions cookbook/views/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,16 @@ def search(request):
RequestConfig(request, paginate={'per_page': 25}).configure(table)

if request.GET == {}:
qs = Recipe.objects.filter(viewlog__created_by=request.user).order_by('-viewlog__created_at').all()[0:5]
qs = Recipe.objects.filter(viewlog__created_by=request.user).order_by('-viewlog__created_at').all()

last_viewed = RecipeTable(qs)
recent_list = []
for r in qs:
if r not in recent_list:
recent_list.append(r)
if len(recent_list) >= 5:
break

last_viewed = RecipeTable(recent_list)
else:
last_viewed = None

Expand Down

0 comments on commit dfb1d80

Please sign in to comment.