23👍
First off remove the semicolon after your replace.
Do you have a file called __init__.py
(this is suppose to have 2 underscores before and after init, hard to format in editor.) under the templatetags directory?
Here is a good page with lots of info if you haven’t looked yet.
http://docs.djangoproject.com/en/dev/howto/custom-template-tags/
38👍
Just for reference, I solved the problem by moving
{% load ... %}
from the base template to the concrete template.
See also this post https://stackoverflow.com/a/10427321/3198502
- [Django]-Generating file to download with Django
- [Django]-Check permission inside a template in Django
- [Django]-What's the difference between staff, admin, superuser in django?
22👍
I was nearly going nuts with this problem and none of the above answers helped.
If you have several apps, make sure that the file names containing your custom tags/filters are unique, prefereablyapp_name_filters.py
. Otherwise Django will only load the custom filters from the app it finds matching first!
- [Django]-What are the best practices to use AngularJS with Django
- [Django]-Django static annotation
- [Django]-AttributeError: module Django.contrib.auth.views has no attribute
3👍
To avoid loading the module in each template using {% load MODULE_NAME %}
, you can add it as a 'builtin'
in settings.py
:
TEMPLATES = [
{
'OPTIONS': {
...
,
'builtins': [
...
'APP_NAME.templatetags.MODULE_NAME',
]
},
},
]
- [Django]-Visual Studio Code: Intellisense not working
- [Django]-What's wrong with "magic"?
- [Django]-How to implement FirebaseDB with a Django Web Application