forked from 00dani/lemoncurry
Add a redirect to entry permalink pages, to ensure entries are only ever accessed at their canonical URL
This commit is contained in:
parent
9bd6bc3d1c
commit
ecdd63b9d7
1 changed files with 3 additions and 1 deletions
|
@ -1,4 +1,4 @@
|
|||
from django.shortcuts import render
|
||||
from django.shortcuts import redirect, render
|
||||
from .models import Entry
|
||||
|
||||
|
||||
|
@ -12,6 +12,8 @@ def index(request, kind):
|
|||
|
||||
def entry(request, id, slug=None):
|
||||
entry = Entry.objects.get(pk=id)
|
||||
if request.path != entry.url:
|
||||
return redirect(entry.url, permanent=True)
|
||||
return render(request, 'entries/entry.html', {
|
||||
'entry': entry,
|
||||
'title': entry.name or entry.content,
|
||||
|
|
Loading…
Reference in a new issue