Last active
February 27, 2018 13:05
-
-
Save nephthys/3db9f4b3b188569838b0 to your computer and use it in GitHub Desktop.
Highlight current page / app in Django
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<ul class="nav navbar-nav"> | |
<li{% if app_name == 'pages' %} class="active"{% endif %}> | |
<a href="{% url "page_list" %}">{% trans "Pages" %}</a> | |
</li> | |
</ul> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Import this context processor in settings TEMPLATE_CONTEXT_PROCESSORS | |
""" | |
def resolver_context_processor(request): | |
return { | |
'app_name': request.resolver_match.app_name, | |
'namespace': request.resolver_match.namespace, | |
'url_name': request.resolver_match.url_name | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf.urls import patterns, include, url | |
from django.contrib import admin | |
urlpatterns = patterns('', | |
url(r'^pages/', include('pages.urls', app_name='pages')), | |
url(r'^documents/', include('documents.urls', app_name='documents')), | |
url(r'^admin/', include(admin.site.urls)), | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment