Hi, 

 

I want to create my own templatetag that returns true if a user is
member of a certain group.

I did the following:

 

Created a package "templatetags" in my app. 

Wrote a module: 

 

from django import template

register = template.Library()

 

def check(user):

    if str(user.groups.all()[0]) == "Timesheet-Boss":

        return True

    else:

        return False

 

Put this in my html:

 

{% load checkers %}

 

{{ check:user  }}

 

I get the following error: 

 

Invalid filter: 'check'

Request Method:

GET

Request URL:

http://localhost:8000/

Django Version:

1.2.4

Exception Type:

TemplateSyntaxError

Exception Value:

Invalid filter: 'check'

 

 

What am i doing wrong ?!

 

Best regards


. . . . . . . . . . . . . . . . . . . . . . . . . .
Ing. Patrick Szabo
 XSLT Developer 
LexisNexis
Marxergasse 25, 1030 Wien

mailto:patrick.sz...@lexisnexis.at
Tel.: 00431 534521573 
Fax: +43 (1) 534 52 - 146 





-- 
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 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to