I am really confused as to how could I load a custom tag filter from another app. I have a similar problem like this Load custom template tag from another application? And, I am doing it the same way, but still it doesnt load up and I am getting this error :
TemplateSyntaxError at /
'fillme_tag' is not a valid tag library: Template library fillme_tag not found, tried django.templatetags.fillme_tag,django.contrib.staticfiles.templatetags.fillme_tag,fillme.templatetags.fillme_tag
I have the app in settings installed app too. I have tried loading it using various ways as mentioned below: {% load fillme_tag %} {% load fillme.fillme_tag %} #filleme is appname.
The structure is as follows:
my_project:
app1:
templates:
index.html (this is where i want to load custom tag)
views.py
__init__.py
fillme:
templatetags:
__init__.py
fillme_tag.py (the tag lib)
__init__.py
----- contents of fillme_tag.py ----
from django import template
register = template.Library()
@register.filter(name='demotag')
def demotag(value):
return value
Registering the tag The tag() method takes two arguments: The name of the template tag – a string. If this is left out, the name of the compilation function will be used. The compilation function – a Python function (not the name of the function as a string).
{% include %} Processes a partial template. Any variables in the parent template will be available in the partial template. Variables set from the partial template using the set or assign tags will be available in the parent template.
Django Code The template tags are a way of telling Django that here comes something else than plain HTML. The template tags allows us to to do some programming on the server before sending HTML to the client.
It seems you missed fillme/__init__.py
. Add it and this must work:
{% load fillme_tag %}
UPDATE
As error message said it couldn't open fillme_tag as it was invalid Library. My guess is you have a typo somewhere.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With