1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | from django.core.urlresolvers import resolve
class GetCurrentViewMiddleware(object):
def process_request(self, request):
try:
current_view = resolve(request.path)[0]
# Handle wrappers
if hasattr(current_view, 'view_func'):
current_view = current_view.view_func
# Saving back to request
setattr(request, 'current_view', '%s.%s' % (current_view.__module__,
current_view.__name__))
except:
pass
|
More like this
- django subdomain support for both resolve and reverse. by puppy 3 years ago
- Decorator to make files downloadable by prigun 4 years, 7 months ago
- Simple View Middleware to allow a Prefilter by tclineks 5 years, 1 month ago
- Serve static media and indexes from app directories [Python2.5, Development only] by adamlofts 4 years, 10 months ago
- CSRF this! by oggy 4 years, 8 months ago
Comments