On 26 juil, 18:00, owidjaya <[email protected]> wrote: > how do i write custom template tag that is available to all my apps. > not tied to a particular app?
You don't have to make your templatetags "available to all your apps" - this would make each app dependants on the others, which is exactly what you don't want (unless you like spaghetti code and maintanance nightmares of course). A django *project* is composed of * one or more apps. * templates * static resources (css, images etc) Most of these apps are designed to provide a specific (and if possible reusable) feature set (blog, news, rss, auth, regitration, contactfrom, whatever). Note that an app doesn't have to provide models - you can have an app that only provides templatetags and filters, or context processors, or middleware, etc... These apps ares usually designed to be as decoupled as possible so you can reuse them from project to project. This of course means that you'll have to do the "integration" works to make these apps work together. This integration work starts in the templates - even if a pluggable app provides it's own, these are usually only defaults / example / starting points. But templates are, well, templates (that is, only presentation logic), and you'll usually need more than this (override pluggable apps views, write your own specific templateetags and filters, whatever...). The obvious solution is to write a project- specific app that'll host all the project-specific code. In your case, put your custom templatetags there, and call them from *your* templates (you do use project-specific templates, don't you ? http://docs.djangoproject.com/en/1.2/ref/templates/api/#the-template-dirs-setting) HTH -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

