1

Below is the snip of code I am using.

<ul class="article_list">
{%for article in articles %}

<li><a href="{{article.title|replace(' ','-')}}">{{article.title}}</a></li>

{%endfor%}
</ul>

This is the exception I get.

Invalid filter: 'replace'
Request Method: GET
Request URL:    http://127.0.0.1:8000/Mathematics/
Django Version: 1.10.5
Exception Type: TemplateSyntaxError
Exception Value:    
Invalid filter: 'replace'

My intention is to redirect user to http://127.0.0.1:8000/mathematics/how-to-use-replace-in-jinga when they click on the article: How to use replace in jinga

Please help.

  • 2
    Because `replace` is jimja's template filter and it is not available in django's default template engine. You can not use jinja's template filters from django's template engine you have to setup jinja as your template engine in your django app – Arpit Solanki Feb 21 '18 at 07:00
  • okay thanks, i'll try. – Sudhan Nadar Feb 21 '18 at 07:03