views:

336

answers:

2

Second time asking more details ...

I'd like to have a project wide templagetags directory to have the common tags used by all Apps, then each app can have their own tags if need so.

Let say that I have:

proj1/app1
proj1/app1/templatetags/app1_tags.py

proj1/app2
proj1/app2/templatetags/app2_tags.py

proj1/templatetags/proj1_tags.py

proj1/templates/app1/base.html
proj1/templates/app1/index.html
proj1/templates/app2/base.html
proj1/templates/app2/index.html

Where:

proj1/templates/app1/base.html
-----------
{% load proj1_tags %}
{% load app1_tags %}

proj1/templates/app1/index.html
-----------
{% extends "base.html" %}

proj1/templates/app2/base.html
-----------
{% load proj2_tags %}
{% load app2_tags %}

proj1/templates/app2/index.html
-----------
{% extends "base.html" %}

Would this work? It didn't work for me. It can't find the proj1_tags to load.

+4  A: 

I don't know if this is the right way to do it, but in my Django apps, I always place common template tags in a lib "app", like so:

proj/
    __init__.py
    lib/
        __init__.py
        templatetags/
            __init.py__
            common_tags.py

Just make sure to add the lib app to your list of installed apps in settings.py.

mipadi
I usually name the app after the project: "project_core" - but same solution.
Carl Meyer
+1  A: 
zgoda