the easiest way is to pass in the context to the template tag :
@register.inclusion_tag("edit_link_tag.html",takes_context=True)
def edit_link_tag(context,obj,name=None):
"""returns a link to edit the model if you have permission to do so
"""
user = context['user']
.... and so on ...
d= { vars here }
# add the vars you need into the context
context.update( d )
# so the user, perms, etc. should all be in there
#and return it for use in the included template
return context
it would be nice if one could do that in a simple tag
@register.simple_tag(takes_context=True)
def displayfields(context,model):
... yada yada yada...
but we can't. I looked at the django code to try to make that work but I
hit a snag and sadly was then distracted by my job.
-flix
On Tue, Oct 21, 2008 at 11:44 PM, [EMAIL PROTECTED] <
[EMAIL PROTECTED]> wrote:
>
> Simple question: is it possible to access all user permissions in
> template tags just as in regular templates through the {{ perms }}
> context variable or do I need to manually pass the permissions are
> template tag params? By default the perms map does not seem to work in
> tags.
> >
>
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---