On 16 oct, 12:34, raeldc <[EMAIL PROTECTED]> wrote:
> Hello Again Guys!
>
> With your guidance, I was able to get a pretty good idea on how to put
> mini-content boxes on my website.
>
> However, one thing I realized (with my still limited understanding of
> Django), is that templatetags are actually coupled with apps. To
> create templatetags, I must make it as a templatetags module inside my
> apps. It doesn't look "loosely coupled" to me if I want to reuse the
> same templatetag on different apps.

It's just like for any function/class/whatever you want to make
reusable in different contexts : put it in a separate package /
module / app.

Since indeed Django requires templatetags to live in a "django
application" - that is, a python package with a more or less defined
layout -, then the solution is obvious:

- start a new 'mycustomtags' app
- move your templatetags to this app
- put that app somewhere in your PYTHONPATH (apps don't have to live
in your project, cf django.contrib.XXX apps)
- and of course mention that app in your project
settings.INSTALLED_APPS

Note that just any 'component' of a django app is optional. IOW, you
don't have to have models AND views AND urls AND whatnot - just put
what makes sense. In your case, your mycustomtemplatetags app layout
would only contain the mandatory[1] top-level __init__.py, the
templatetags directory - with it's own mandatory __init__.py -, and
your templatetags file(s). FWIW, that's just what the template_utils
app do:
http://code.google.com/p/django-template-utils/

1] mandatory to make Python consider this directory as a Python
package.

HTH


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to