misc: don't crash error pages in metanav
authorFrédéric Péters <fpeters@0d.be>
Sun, 8 Mar 2020 09:56:02 +0000 (10:56 +0100)
committerFrédéric Péters <fpeters@0d.be>
Sun, 8 Mar 2020 09:56:02 +0000 (10:56 +0100)
panikweb/paniktags/templatetags/paniktags.py

index b6d468d..a8f9e7d 100644 (file)
@@ -131,7 +131,11 @@ def player(context):
 
 @register.inclusion_tag('includes/metaNav.html', takes_context=True)
 def metanav(context, active=None):
-    request_path = context['request'].path
+    try:
+        request_path = context['request'].path
+    except KeyError:
+        # a context without 'requests' may happen when rendering error pages
+        request_path = 'xxx'
     section = 'About'
     if request_path == '/':
         section = 'Home'