Add function to build canonical url
This commit is contained in:
parent
e8d73b9909
commit
b59377471a
6 changed files with 87 additions and 41 deletions
|
@ -11,6 +11,8 @@ from django.urls import reverse
|
|||
from django.views import View
|
||||
from django.views.generic import DetailView, ListView, TemplateView
|
||||
|
||||
from gallery.utils import build_canonical_url
|
||||
|
||||
from ..models import Album, Photo, Redir
|
||||
|
||||
|
||||
|
@ -20,8 +22,14 @@ class Main(TemplateView):
|
|||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['canonical_url'] = self.request.build_absolute_uri(reverse('gallery:main_url'))
|
||||
context['latest_albums'] = Album.objects.filter(is_public=True).order_by('-album_date')[:6]
|
||||
canonical_url = build_canonical_url(
|
||||
self.request,
|
||||
reverse('gallery:main_url')
|
||||
)
|
||||
context.update({
|
||||
'canonical_url': canonical_url,
|
||||
'latest_albums': Album.objects.filter(is_public=True).order_by('-album_date')[:6],
|
||||
})
|
||||
return context
|
||||
|
||||
|
||||
|
@ -31,7 +39,11 @@ class About(TemplateView):
|
|||
|
||||
def get_context_data(self, **kwargs):
|
||||
context = super().get_context_data(**kwargs)
|
||||
context['canonical_url'] = self.request.build_absolute_uri(reverse('gallery:about_url'))
|
||||
canonical_url = build_canonical_url(
|
||||
self.request,
|
||||
reverse('gallery:about_url')
|
||||
)
|
||||
context['canonical_url'] = canonical_url
|
||||
return context
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue