{% gen_aws "hello" %}
In my file, I do this:
#I want to add "goodbye" to every word passed to this tag. @register.tag(name="gen_aws") def gen_aws(s): return s + "goodbye"
The .py file is fine ... I include everything in order. I have other "filter" templates that work fine. But then I added this to this file, and this template tag does not work.
Your description of "not working" is not very accurate (more precisely, it does not exist). But I think you will get an error because the tag was not found.
The documentation clearly states that you need the "templatetags" module in your application, for example, a submodule, such as "mytags". Then you must include these tags in each template that you want to use. You can do this with {% load mytags %}.
{% load mytags %}
"mytags" "gen_aws" .
: "gen_aws() 1 (2 )" , . "" "" . - Django Python. @register.tag @register.simple_tag.
@register.tag
@register.simple_tag
"no attribute 'must_be_first'" , django.template.Node . ( Google , , , .)
"no attribute 'must_be_first'"
django.template.Node
Source: https://habr.com/ru/post/1791167/More articles:Fill the remaining screen height with CSS - cssGetting a dte2 or TeamFoundationServerExt object in a VS package project? - c #Options for off-screen rendering on Android with OpenGL ES 1.0? - androidConvert bidding topics to gvim colorscheme - vimConstants in the Android SDK - android-layoutOracle ODBC: why national characters changed to Latin equivalent as a result of SELECT - oracleОткуда берется максимальная длина 255 для полей CHAR? - mysqlScala DBs? Relational Algebra? - databasedifference between template and layout template - asp.netSafari 5 on Mac freezes when downloading files - safariAll Articles