Exception Value:
UserProfile matching query does not exist.
def PostList(request):
all_posts = Post.objects.order_by('-timestamp').all()
paginator = Paginator(all_posts, 3)
page = request.GET.get('page', 1)
try:
posts = paginator.page(page)
except PageNotAnInteger:
raise Http404
except EmptyPage:
posts = paginator.page(paginator.num_pages)
post_votes = {}
if request.user.is_authenticated:
for post in posts:
try:
vote = Vote.objects.get(vote_object_type=post.get_content_type(), vote_object_id=post.id, user=UserProfile.objects.get(user=request.user))
post_votes[post.id] = vote.value
except Vote.DoesNotExist:
pass
return render(request, 'posts/post_list.html', {'posts': posts, 'post_votes': post_votes})