use render_to_string for template processing, add count and unique value columns, safeguard exceptions