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
- Resolve URLs to view name and args/kwargs by fahhem 1 year, 6 months ago
- Middleware that fixes URLs generation for admin and {% url %} for SCGI and WSGI by dottedmag 4 years, 10 months ago
- SSL Middleware by sjzabel 5 years, 2 months ago
- AdminPeepingMiddleware by buriy 4 years, 8 months ago
- A GET string modifier templatetag by cogat 3 years, 5 months ago
Comments