Код: Выделить всё
TemplateSyntaxError at /attainment/reportcard/
Invalid filter: 'get_item'
Request Method: POST
Request URL: http://127.0.0.1:8000/attainment/reportcard/
Django Version: 1.11.5
Exception Type: TemplateSyntaxError
Exception Value:
Invalid filter: 'get_item'
Exception Location: /media/itsd/ITSD/ROFI/Projects/Rise/venv/lib/python3.5/site-packages/django/template/base.py in find_filter, line 606
Python Executable: /media/itsd/ITSD/ROFI/Projects/Rise/venv/bin/python
Python Version: 3.5.2
template_filters.py
Код: Выделить всё
from django.template.defaulttags import register
# Custom template filter to get data from a dictionary using key in template
@register.filter
def get_item(dictionary, key):
return dictionary.get(key)
Код: Выделить всё
{% for subject in subjects %}
{{ subject|get_item:"subject" }}
{{ subject|get_item:"efffort" }}
{{ subject|get_item:"homework" }}
{{ subject|get_item:"marks" }}
{{ subject|get_item:"grade" }}
{% endfor %}
Примечание: я последовал этому ответу.
Подробнее здесь: https://stackoverflow.com/questions/477 ... ate-filter
Мобильная версия