Comparing numbered urls in django template

"In I have:

path("viewer/<str:case>", views.viewer, name="viewer"),

This works when I go to the viewer:

<a class="nav-link dropdown-toggle {% if request.resolver_match.url_name == "viewer" %}active{% endif %}">

Now, there is a submenu in nav bar that lists cases. I need to know which specific page I'm on to make one of menu items active:

{% for item in cases %}   
  <a class="dropdown-item {% if request.get_full_path == "/viewer/{{ }}" %}active{% endif %}" href="/viewer/{{ }}">{{ item.patient_name }}</a>

request.get_full_path returns /viewer/47 for example and one of the item's id is 47. I've tried different combinations instead of "/viewer/{{ }}", nothing works.

I ended up creating a custom template tag:
def url_case_id(value):
    return int(value.split("/")[2])

and using it in html:

{% for item in cases %}  
{% url_case_id request.get_full_path as id %} 
  <a class="dropdown-item {% if id == %}active{% endif %}" href="/viewer/{{ }}">{{ }}</a>
Back to Top