Hello, I am making some view functions to calculate the rank of one user in a community. My problem is that i want to display the rank afferent to each user, in its profile, and i don't know how, since i don;t have a request and a render_to_response (cause i guessed they are not needed) my code:
def calculate_questions_vote(request):
useranswer = Answer.objects.filter (answer_by = request.user)
positive_votes = VoteUpAnswer.objects.filter(answer = useranswer)
negative_votes = VoteDownAnswer.objects.filter(answer = useranswer)
question_vote_rank = sum(positive_votes) - sum(negative_votes.count)
return question_vote_rank
def calculate_replies(request):
the_new = News.objects.filter(created_by = request.user)
reply = Reply.objects.filter(reply_to = the_new)
reply_rank = sum(reply)
return reply_rank
def calculate_votes(request):
the_new = News.objects.filter(created_by = request.user)
vote = Vote.objects.filter(voted = the_new)
vote_rank = sum(vote)
return vote_rank
def personal_rank(request):
personal_rank = question_vote_rank + reply_rank + vote_rank
return personal_rank
and in UserProfiles:
user = request.user
personal_rank = calculate_questions_vote(user) + calculate_replies(user) + personal_rank(user)
but my error is:
Error binding parameter 0 - probably unsupported type.
Is mt approach correct? How should i call the rank function in the profile_view def ?
Thanks!