From 3f12e07cc7c4e60d8490f8dc82bc12244d7081ac Mon Sep 17 00:00:00 2001
From: Tor-Einar Skog <tor-einar.skog@bioforsk.no>
Date: Fri, 9 Jan 2015 11:16:48 +0100
Subject: [PATCH] Bugfix

---
 information/models.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/information/models.py b/information/models.py
index 02dbdaa1..d1133864 100644
--- a/information/models.py
+++ b/information/models.py
@@ -20,6 +20,8 @@ class InformationLocale(models.Model):
     
     @staticmethod
     def get_information_locale_with_fallback(information_id, language_code=translation.get_language()):
+        if information_id == None:
+            return ""
         # Try with user's preferred locale first
         try:
             return InformationLocale.objects.get(
@@ -42,7 +44,9 @@ class InformationLocale(models.Model):
                                                        )
                 except:
                     # Use the first and best
-                    return InformationLocale.objects.all()[0]
+                    return InformationLocale.objects.get(
+                                                         information=Information.objects.get(pk=information_id)
+                                                         )[0]
     
     @staticmethod
     def get_heading_with_fallback(information_id, language_code=translation.get_language()):
-- 
GitLab