Skip to content

Instantly share code, notes, and snippets.

@robyoung
Created October 12, 2010 13:08
Show Gist options
  • Save robyoung/622137 to your computer and use it in GitHub Desktop.
Save robyoung/622137 to your computer and use it in GitHub Desktop.
import traceback
def app_view_processor(request):
"""Add the current application and view names to the context."""
params = {}
for item in reversed(traceback.extract_stack()):
if item[0].endswith("/views.py"):
params['CURRENT_APP'] = item[0].split("/")[-2]
params['CURRENT_VIEW'] = item[2]
return params
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment