[Answered ]-Unsupported operand type(s) for /: 'NoneType' and 'NoneType'

2👍

Just implement a simple type/value check for num1 and num2:

@register.simple_tag()
def average(num1, num2):
    if num1 and num2 and num1 != 0 and num2 != 0:
        return round(float(num1 / num2), 2)
    return 'Your error message'

0👍

Why not add an if statement which checks for ‘0’ or None?

👤blasko

Leave a comment