lang switcher set to main on 404
authorRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Wed, 24 Oct 2012 14:36:53 +0000 (16:36 +0200)
committerRadek Czajka <radoslaw.czajka@nowoczesnapolska.org.pl>
Wed, 24 Oct 2012 14:36:53 +0000 (16:36 +0200)
fnpdjango/templatetags/fnp_lang.py

index 7f08496..006faec 100755 (executable)
@@ -35,17 +35,14 @@ def get_here_url(request, lang):
         try:
             match = resolve(request.get_full_path())
         except Resolver404:
         try:
             match = resolve(request.get_full_path())
         except Resolver404:
-            return None
+            match = resolve('/')
         view = match.url_name
         if view is None:
             view = match.func
         if lang is None:
             lang = translation.get_language()
         with translation.override(lang):
         view = match.url_name
         if view is None:
             view = match.func
         if lang is None:
             lang = translation.get_language()
         with translation.override(lang):
-            try:
-                url = reverse(view, args=match.args, kwargs=match.kwargs)
-            except Resolver404:
-                return None
+            url = reverse(view, args=match.args, kwargs=match.kwargs)
     return url
 
 
     return url