title: django writing my first custom template tag and filter
body: <p>I am attempting to write a simple django <a href="https://docs.djangoproject.com/en/1.4/howto/custom-template-tags/" rel="nofollow">Custom template tags and filters</a> to replace a html break (&lt; b r / >) with a line space on a template.</p>
  
  <p>I have followed the django docs, but I am getting the following error, which I don't know how to solve.</p>
  
  <p>The error I have is:</p>
  
  <pre><code>x_templates_extra' is not a valid tag library: Template library x_templates_extra not found, tried django.templatetags.x_templates_extra,django.contrib.staticfiles.templatetags.x_templates_extra,django.contrib.admin.templatetags.x_templates_extra,django.contrib.flatpages.templatetags.x_templates_extra,rosetta.templatetags.x_templates_extra,templatetag_handlebars.templatetags.x_templates_extra,globalx.common.templatetags.x_templates_extra,rollyourown.seo.templatetags.x_templates_extra,debug_toolbar.templatetags.x_templates_extra
  </code></pre>
  
  <p>Here is what I have done:</p>
  
  <pre><code>1. created a templatetags directory, at the same level as models.py, views.py, etc
  
  2. created a __init__.py file inside the templatetags directory to ensure the directory is treated as a Python package
  
  3. created a file inside the templatetags directory called x_templates_extra.py
  
  4. added the load tag to the template: {% load x_templates_extra %}
  
  5. added the tag to the template: {{ x_detail.x_details_institution_name|safe|replace:"&lt;br /&gt;"|striptags|truncatechars:popover_string_length_20 }}
  
  6. Added the following code to the file x_templates_extra.py:
  
  from django import template
  
  register = template.Library()
  
  def replace(value, arg):
     """Replaces all values of arg from the given string with a space."""
      return value.replace(arg, ' ')
  </code></pre>
  
  <p><strong>Question:</strong></p>
  
  <p>The docs state that: So, near the top of your module, put the following:</p>
  
  <pre><code>from django import template
  
  register = template.Library()
  </code></pre>
  
  <p>I have put the import &amp; register lines in my file called: called x_templates_extra.py. Is that correct?</p>
  
  <p>Also I am not sure what to put in the INSTALLED_APPS to make the load work.</p>
  
  <p>Tried many things, but I am now going in circles, so I do need help.</p>
  
  <p>Thanks.</p>