From e921c88ecc831aea4e68b93649e68392e48b657f Mon Sep 17 00:00:00 2001 From: Iacopo Spalletti Date: Thu, 19 Nov 2015 19:51:06 +0100 Subject: [PATCH] Ensure correct creation of full URL for canonical urls --- .../templates/djangocms_blog/post_detail.html | 2 +- .../templates/djangocms_blog/post_list.html | 4 ++-- djangocms_blog/views.py | 3 ++- tests/test_utils/templates/blog.html | 1 + tests/test_views.py | 12 ++++++++++-- 5 files changed, 16 insertions(+), 6 deletions(-) diff --git a/djangocms_blog/templates/djangocms_blog/post_detail.html b/djangocms_blog/templates/djangocms_blog/post_detail.html index 1ca1fe3..6c5fc8b 100644 --- a/djangocms_blog/templates/djangocms_blog/post_detail.html +++ b/djangocms_blog/templates/djangocms_blog/post_detail.html @@ -3,7 +3,7 @@ {% block meta_description %}{{ post.meta_description }}{% endblock meta_description %} {% block meta_keywords %}{{ post.meta_keywords }}{% endblock meta_keywords %} -{% block canonical_url %}{% endblock canonical_url %} +{% block canonical_url %}{% endblock canonical_url %} {% block title %}{{ post.get_title }}{% endblock %} {% block content_blog %}{% spaceless %} diff --git a/djangocms_blog/templates/djangocms_blog/post_list.html b/djangocms_blog/templates/djangocms_blog/post_list.html index 9af3416..74f405d 100644 --- a/djangocms_blog/templates/djangocms_blog/post_list.html +++ b/djangocms_blog/templates/djangocms_blog/post_list.html @@ -1,7 +1,7 @@ {% extends "djangocms_blog/base.html" %} {% load i18n thumbnail %}{% spaceless %} -{% block canonical_url %}{% endblock canonical_url %} +{% block canonical_url %}{% endblock canonical_url %} {% block content_blog %}
@@ -38,4 +38,4 @@ {% endif %}
{% endblock %} -{% endspaceless %} \ No newline at end of file +{% endspaceless %} diff --git a/djangocms_blog/views.py b/djangocms_blog/views.py index 758130e..c53ab31 100644 --- a/djangocms_blog/views.py +++ b/djangocms_blog/views.py @@ -26,12 +26,13 @@ class BaseBlogView(AppConfigMixin, ViewUrlMixin): 'Missing `view_url_name` attribute on {0}'.format(self.__class__.__name__) ) - return reverse( + url = reverse( self.view_url_name, args=self.args, kwargs=self.kwargs, current_app=self.namespace ) + return self.request.build_absolute_uri(url) def get_queryset(self): language = get_language() diff --git a/tests/test_utils/templates/blog.html b/tests/test_utils/templates/blog.html index f46def0..7916c68 100644 --- a/tests/test_utils/templates/blog.html +++ b/tests/test_utils/templates/blog.html @@ -4,6 +4,7 @@ {% block title %}{% page_attribute 'title' %}{% endblock title %} {% render_block "css" %} + {% block canonical_url %}{% endblock canonical_url %} {% include "meta_mixin/meta.html" %}