When a template variable
value is None, is it expected to render the word 'None'? I would expect this to
fail silently instead of displaying the word. Is there a configuration setting
or some way to change the default rendering? Do I have to wrap variables with
an {% if ... %} in order to not display None? I would appreciate any
suggestions on how to handle the display of variables equal to None.
Are you looking for this :
http://www.djangoproject.com/documentation/templates/#default-if-none
Chris
Is that the designed behavior template variables? If the value is
None, display the word "None"? So someone has to use the
default_if_none filter or use a conditional expression in order to
render an empty string for all variables that have the potential value
of None? In my opinion, this seems counter-intuitive, and a better
approach might be to render an empty string by default, and use the
default_if_none filter to render the word 'None' if desired.
>>> str(None)
'None'
I don't agree that it should be the default. None and "" are two
distinct values -- especially with a database. In databases, None (or
NULL) normally represents a _missing_ value, whereas a "" is one that
was intentionally specified to be blank.