On Jan 24, 10:36 pm, hifire <[EMAIL PROTECTED]> wrote:
> Greetings group!
>
> I've been trying to get this code to 
> work:http://www.djangosnippets.org/snippets/282/
>
> I created a templatetags folder in my app, and added __init__.py and
> usertags.py. I pasted the code from the snippets site into my
> usertags.py. I have a view define like this:
>
> @login_required
> def user_home(request):
>
>     return render_to_response('master/template/user_home.html',
>                               {},
>
> context_instance=RequestContext(request),)
>
> And my user_home.html looks like this:
>
> {% load usertags %}
>
> {% ifusergroup member %}
>         You are a member.
> {% endifusergroup %}
>
> This works, but I don't understand why I can't call render_to_response
> like so:
>
> render_to_response('master/template/user_home.html')
>
> I've read over the "Extending the Template Engine" chapter of the book
> but I feel like I keep getting further from an answer.

Unless you pass the request context to your template (using
context_instance=RequestContext(request)), the ifusergroup templatetag
can't tell who the logged in user is.

See this section of the docs:
http://www.djangoproject.com/documentation/authentication/#authentication-data-in-templates



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