views.py: Add 'nv': 'view_name', to the context data of each view
return render(request, 'app_fossils/home.html', {
...
"nv": "home",
})
navbar.hml: for each link add: {% if nv == 'view_name' %}active{% endif %}"
views.py: Add 'nv': 'view_name', to the context data of each view
return render(request, 'app_fossils/home.html', {
...
"nv": "home",
})
Add new folders inside the app_fossils directory, inside templatetags add __init__.py and navbar_tags.py
app_fossils
templatetags
__init__.py
navbar_tags.py
navbar_tags.py: Create a new custom template tag
navbar.html:
At the top of the page load the new tag:
Update each link adding {% is_active 'view_name' %}: