Hi everyone, Scenario: I want to build a main menu with several entries. Some of the entries should only be displayed if the user is logged in (profile, settings), some only if it's an anonymous user (register, log in) and some entries should be always visible (home, ...).
I tried it several ways now, but I just don't get it. The only way I found working is to do everything in the views.py and pass a dict with the menu entries to my template. As the menu is something that is displayed on every single page, there must be a better way to do this. So far, I tried to code an own template tag, an inclusion_tag and much more to automate this for every page, but I always fail as I cannot get access to the current user object in the custom template tag code. It always tells me that the RequestContext object does not have a user attribute: File "/usr/lib/python2.4/site-packages/django/template/__init__.py", line 733, in render_node raise wrapped TemplateSyntaxError: Caught an exception while rendering: 'RequestContext' object has no attribute 'user' Original Traceback (most recent call last): File "/usr/lib/python2.4/site-packages/django/template/__init__.py", line 723, in render_node result = node.render(context) File "/usr/lib/python2.4/site-packages/django/template/__init__.py", line 883, in render dict = func(*args) File "/www/mysite/dj_proj/lib/templatetags/Menus.py", line 41, in top_menu_tag if context.user.is_authenticated(): AttributeError: 'RequestContext' object has no attribute 'user' Could somebody point me somewhere, just to get an idea how to solve this or, even better, how to to such dynamic menus based on user objects? TIA. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---