Here's one method of importing a common set of tags into your
app-specific templatetags modules. If there's an easier way, I'd
appreciate the advice.

1. Define your common tags, e.g. /yourproject/apps/templatetags.py:

from django import template

register = template.Library()

def some_common_op(x, y):
  return 'some string value'
register.simple_tag(some_common_op)

2. An individual app's templatetags, e.g.
/yourproject/apps/blog/templatetags/mytags.py:
(Don't forget an __init__.py in the same directory.))

from yourproject.apps import templatetags

register = templatetags.register

def some_comment_op(x, y):
  return 'some string value'
register.simple_tag(some_comment_op)

3. In one of your blog templates, use:

{% load mytags %}

I've read that 'load' should come after and 'extends' -- I didn't
encounter that issue, but some circumstance might require it.

- David


--~--~---------~--~----~------------~-------~--~----~
 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