9

I tried to print this in the template, but it renders blank. Whats the correct way to get URL name in template?

{{ request.resolver_match.url_name }}

I wanted it to highlight something in the top bar (if path is 'admin-stuff' add highlight class).

Jesvin Jose
  • 22,498
  • 32
  • 109
  • 202

1 Answers1

7

In the application settings TEMPLATE_CONTEXT_PROCESSORS must include

"django.core.context_processors.request"

for the request to appear in the template context.

Jesvin Jose
  • 22,498
  • 32
  • 109
  • 202