mitar avatar mitar committed d8a4939

Blog entries are not unique by slug anymore, but also by language.

Comments (0)

Files changed (1)


     def _get_blog(self, res, ctx=None):
         blog_id =
         if not blog_id: # links like [blog: current blog entry]
             request = _get_django_request(res=res, ctx=ctx)
             context = _get_django_context(res=res, ctx=ctx)
             except blog_models.EntryTitle.MultipleObjectsReturned as e:
                 # Should not happen
                 raise blog_models.EntryTitle.DoesNotExist(e)
-            return blog_models.EntryTitle.objects.get(slug=blog_id)
+            ids = blog_id.split(":", 1)
+            if len(ids) == 1:
+                blog_id = ids[0]
+                entries = blog_models.EntryTitle.objects.filter(slug=blog_id)
+                if len(entries) == 0:
+                    raise blog_models.EntryTitle.DoesNotExist
+                elif len(entries) == 1:
+                    return entries[0]
+                else:
+                    lang = django_translation.get_language()
+                    return entries.get(language=lang)
+            else:
+                (lang, blog_id) = ids
+                return blog_models.EntryTitle.objects.get(slug=blog_id, language=lang)
     def _get_plugin(self, request, context):
         if context and context.get('object'):
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.