Finally, we will need a way to display the activity stream for each user. We will include the activity stream in the user's dashboard. Edit the views.py file of the account application. Import the Action model and modify the dashboard view, as follows:
from actions.models import Action@login_requireddef dashboard(request): # Display all actions by default actions = Action.objects.exclude(user=request.user) following_ids = request.user.following.values_list('id', flat=True) if following_ids: # If user is following others, retrieve only their actions actions = actions.filter(user_id__in=following_ids) actions = actions[:10] return render(request, 'account/dashboard.html', {'section': 'dashboard', 'actions': actions ...