1

This is a pretty routine thing I do:

{{ data['key'] or '' }} so it won't display None, but it also won't display a 0 and sometimes-- most of the time-- I really need 0 values to show, but never a None.

What's the easiest fix for this? Something like {{ data['key']|none('') }} where none is a filter returning a blank if the value is None?

Or something checking for a non-None value inside the {{ ... }} tags? What's your quick fix here?

Wells
  • 10,415
  • 14
  • 55
  • 85

1 Answers1

2
{{ data['key'] if data['key']!=None else '' }}
r-m-n
  • 14,192
  • 4
  • 69
  • 68