I'm getting this error -> Invalid filter: 'cutter' while this is my custom tags.py:
from django import template
from random import randint
register = template.Library()
def cutter(list, args):
return list[args]
register.filter('cutter', cutter)
a short part of index.html:
{% extends 'main.html' %}
{% load custom_tags %}
{% load humanize %}
{% load static %}
{% block title %}main{% endblock title %}
{% block home %}active{% endblock home %}
{% block body %}
<span>{{regions_count|cutter:forloop.counter0}}</span>
{% endblock body %}
and my directory is this:
my_app/
├── ...
├── templatetags/
│ ├── __init__.py
│ └── _pycache_(folder)
| └── custom_tags.py
└── views.py
I tried it with following:
custom_tags.py (list is a bad name for a variable - because it shadows built in list function)
index.html:
views.py:
and this directory structure:
Everything works fine and I get the first Region object printed.