How to load app specific template tag in Django?

本小妞迷上赌 提交于 2019-12-13 06:03:50

问题


I'm calling this template tag from a different app within the same project. However I'd like to make changes on it to make it work better on the app I'm working on.

I simply created a templatetags directory inside my app and copied the template tag file inside then went about my changes. So it kinda looks like this:

theotherapp/templatetags/sometags.py
myapp/templatetags/sometags.py

What I noticed is that the other app's template tag is still the one being used. But when I change the filename of the template tag in my app ...

myapp/templatetags/sometags.py -> myapp/templatetags/sometags_myapp.py

and then rename the template tags loaded to the new one in my script, it works as intended. But I don't want to do it that way.

My question is:
How do I let Django know to use the template tag script local to my app given that it has the same filename with another app's template tag?

But I'd still like to retain that Django still looks into the other app's template tags as the other apps in the projects are depending on it.

I'm using Django 1.3 by the way.

来源:https://stackoverflow.com/questions/16050990/how-to-load-app-specific-template-tag-in-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!