Package: edc-navbar
edc_navbarSimple Navbar class for edcInstallationIncludeedc_navbar.apps.AppConfiginINSTALLED_APPS.OveriewNavbars are declared in your appsnavbars.pyand will be autodiscovered byedc_navbarand stored in the  site globalsite_navbars.By default, a basic navbar is added to the site global. For it to load you need to define the named urls forhome_url,administration_urlandlogout_urlin your main projecturls.py. The named urls defined in the default navbar do not include a namespace.For example, in the “main” project appurls.py:urlpatterns=[...path('login',LoginView.as_view(),name='login_url'),path('logout',LogoutView.as_view(pattern_name='login_url'),name='logout_url'),path('admininistration/',AdministrationView.as_view(),name='administration_url'),path('',HomeView.as_view(manual_revision='1.0'),name='home_url'),...]You can change thedefaultnavbar to another navbar by settingsettings.DEFAULT_NAVBARto the name of your custom navbar. You will need to declare and register your custom navbar manually. Seeedc_navbar.navbars.The default template forNavbarItemisnavbar_item.html. You can declare a custom template on theNavbarItem.Render the NavbarFor example, in base.html:{%loadedc_dashboard_extras%}...{%show_edc_navbar%}...The rendered html comes fromedc_navbar.htmlDeclaring and registering a navbarA navbar is defined and registered to the site global in thenavbars.pymodule of each app that needs a navbar.An examplenavbars.py:fromedc_navbarimportNavbarItem,site_navbars,Navbarurl_namespace='edc_pharmacy_dashboard'# instantiate a Navbarpharmacy_dashboard=Navbar(name='pharmacy_dashboard')# add items to the navbarpharmacy_dashboard.register(NavbarItem(name='prescribe',title='Prescribe',label='prescribe',glyphicon='glyphicon-edit',url_name=f'{url_namespace}:prescribe_listboard_url'))pharmacy_dashboard.register(NavbarItem(name='dispense',title='Dispense',label='dispense',glyphicon='glyphicon-share',url_name=f'{url_namespace}:dispense_listboard_url'))# register the navbar to the sitesite_navbars.register(pharmacy_dashboard)Accessing the navbar in your viewsNext, addNavbarViewMixinto your views and set the navbar by name. The navbar will be rendered to string and added to the view context.fromedc_navbarimportNavbarViewMixinclassHomeView(EdcViewMixin,NavbarViewMixin,TemplateView):navbar_name='pharmacy_dashboard'navbar_selected_item='prescribe'Rendering Navbar itemsThe default template forNavbarItemisnavbar_item.html. You can declare a custom template on theNavbarItem.Permissions per NavbarItemEach NavbarItem can declare a Django permissionscodename. The codename will be associated with modeledc_navbar.navbar.For example:fromedc_navbarimportNavbarItem,site_navbars,Navbarurl_namespace='edc_pharmacy_dashboard'# instantiate a Navbarpharmacy_dashboard=Navbar(name='pharmacy_dashboard')# add items to the navbarpharmacy_dashboard.register(NavbarItem(name='prescribe',title='Prescribe',label='prescribe',glyphicon='glyphicon-edit',permissions_codename='nav_pharmacy_prescribe',url_name=f'{url_namespace}:prescribe_listboard_url'))pharmacy_dashboard.register(NavbarItem(name='dispense',title='Dispense',label='dispense',glyphicon='glyphicon-share',permissions_codename='nav_pharmacy_dispense',url_name=f'{url_namespace}:dispense_listboard_url'))# register the navbar to the sitesite_navbars.register(pharmacy_dashboard)From the above, you can referenceedc_navbar.nav_pharmacy_prescribeandedc_navbar.nav_pharmacy_dispensein your code.{%ifperms.edc_navbar.nav_pharmacy_dispense%}href="some_url"{%else%}disabled{%endif%}See also:https://github.com/clinicedc/edc-authhttps://docs.djangoproject.com/en/2.1/topics/auth