[Answer]-Best way to pass current Django view's name into the template?

1👍

You could use a Context Processor to fill this information and have it automatically in all you templates

from django.core.urlresolvers import resolve


def custom_context_processor(request):
    return {'view_name': resolve(request.path)[0]}

you can than add this context processor in your settings to the TEMPLATE_CONTEXT_PROCESSORS tuple. That way you can access it in every templates like in the following snippet :

{{ view_name }} 

Leave a comment