From 598c4ab59d60beb06ca13d8c3a579e086b6b6b74 Mon Sep 17 00:00:00 2001 From: Rodolphe Breard Date: Thu, 6 Feb 2020 12:39:44 +0100 Subject: [PATCH] Quickfix for navbar export --- navbar/models.py | 2 +- navbar/templatetags/navbar.py | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/navbar/models.py b/navbar/models.py index 8f5438e..ae58439 100644 --- a/navbar/models.py +++ b/navbar/models.py @@ -39,7 +39,7 @@ class Element(models.Model): def localized_link(self): link = self.link desc = self.description() - if desc.link_override: + if desc and desc.link_override: link = desc.link_override return link diff --git a/navbar/templatetags/navbar.py b/navbar/templatetags/navbar.py index 6cea832..3b3b0ce 100644 --- a/navbar/templatetags/navbar.py +++ b/navbar/templatetags/navbar.py @@ -25,7 +25,10 @@ def get_lang_data(path_info, lang_code, curr_lang): lang_name = get_lang_name(lang_code) rm = resolve(path_info) activate_lang(lang_code) - lang_url = reverse(rm.view_name, current_app="npb", args=rm.args, kwargs=rm.kwargs) + if path_info == "/": + lang_url = f"/{lang_code}/" + else: + lang_url = reverse(rm.view_name, current_app="npb", args=rm.args, kwargs=rm.kwargs) activate_lang(curr_lang) return (lang_code, lang_name, lang_url)