[Django]-In Django templates, firstof or default?

3👍

default can be considered a specialized case of firstof.

firstof outputs the first variable that is not False – Think of the or clause – it evaluates until any one of the objects evaluate to True and returns that.

It can be used to compare multiple values, whereas default is used for a specific object.

default outputs the specified default value if the object evaluates to False

Leave a comment