title: jinja2 Custom filter "TemplateAssertionError: no filter named 'format_number'"
body: <p>I'm getting the "<strong>TemplateAssertionError: no filter named 'format_number'</strong>" error, when trying to register a custom filter on the template environment by updating the filters dict on the environment.</p>
  
  <p>In my module, I have imported environment module as follows:</p>
  
  <pre><code>from jinja2 import environment 
  </code></pre>
  
  <p>In my class I defined the following method:</p>
  
  <pre><code>class DashboardHandler(SecurePageHandler):
  
     def format_number(number):
          s = '%d' % number
          groups = []
          while s and s[-1].isdigit():
              groups.append(s[-3:])
              s = s[:-3]
          return s + ','.join(reversed(groups))
  
      def do_get(self):
              # ... snip ...
              env = environment.Environment(self)
              env.filters['format_number'] = self.format_number
              # ... snip ...
  </code></pre>
  
  <p>Inside my html template file I tried to implement the filter as follows:</p>
  
  <pre><code>{{top_five_url .total|format_number}}
  </code></pre>
  
  <p>How is this happening? </p>
  
  <p>Is there a default environment instance, we should use?</p>