How do I pass user information to admin templates in Django?
I have overridden some admin templates by copying them to my project/templates/admin/... and editing them. I'm now trying to do some simple theming in the templates that require knowing who is viewing the pages, but some pages like add/edit pages aren't getting 'user' passed in their context. I find this a bit strange since change_list pages are getting this in their context.
Here's the error I'm开发者_C百科 getting.
django.template.TemplateSyntaxError
TemplateSyntaxError: Caught VariableDoesNotExist while rendering: Failed lookup for key [user] in u"[{'csrf_token': <django.utils.functional.__proxy__ object at 0x108fb9e50>, 'show_delete_link': False, 'show_save': True, 'show_save_as_new': False, 'onclick_attrib': '', 'is_popup': False, 'show_save_and_add_another': True, 'show_save_and_continue': True}]"
What about using request.user instead of user? Maybe that would work.
精彩评论