1👍
✅
Template tags folder must be beside of templates folder, views.py, models.py, …
//Don't forget also to put __init__.py outside the templatetags,
@register.simple_tag
def ownership(project, user):
return project.added_by_user == user
1👍
If your App name is MyApp
and your tag folder name is templatetags
then in settings.py
you should have :
INSTALLED_APPS = [
'MyApp',
'MyApp.templatetags'
]
Both your app
and your tag folder
which is under your app package
Django Project are needed there.
-> MyApp
---> models.py
---> views.py
---> templatetags
-----> __init__.py
-----> app_filters.py
- [Answered ]-Django Editable Text Field
- [Answered ]-Django foreign key saving with file name not object
- [Answered ]-Can I return a response in a function within a view function?
- [Answered ]-Using a dictionary (or other structure) key in a variable name
- [Answered ]-Using current user to initialize ForeignKey user in Django CreateView
Source:stackexchange.com