You can't directly call the function in django template engine. You can achieve this using django template filters. Try this way,
from django import template
register = template.Library()
@register.filter
def my_points(idemployee):
answer_query = answers.objects.select_related(
'question').filter(empleado=idemployee)
points_total = 0
match = 0
for answer in answer_query:
if answer.question.golesEquipoA == answer.equipoA and answer.question.golesEquipoB == answer.equipoB:
points_total += 4
match += 1
else:
if answer.question.golesEquipoA == answer.question.golesEquipoB and answer.equipoA == answer.equipoB:
points_total += 3
match += 1
else:
if answer.question.golesEquipoA < answer.question.golesEquipoB and answer.equipoA < answer.equipoB:
points_total += 3
match += 1
if answer.question.golesEquipoA > answer.question.golesEquipoB and answer.equipoA > answer.equipoB:
points_total += 3
match += 1
args = {}
args['points'] = points_total
args['match'] = match
return args
https://docs.djangoproject.com/en/dev/howto/custom-template-tags/#writing-custom-template-filters