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
  • 21,648
  • 30
  • 102
  • 191

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
  • 21,648
  • 30
  • 102
  • 191