forked from 00dani/lemoncurry
Make the permalink views 404 if you try to load a non-existent entry
This commit is contained in:
parent
756e3478d8
commit
039b6a1914
1 changed files with 3 additions and 3 deletions
|
@ -1,11 +1,11 @@
|
|||
from annoying.decorators import render_to
|
||||
from django.shortcuts import redirect
|
||||
from django.shortcuts import redirect, get_object_or_404
|
||||
from ..models import Entry
|
||||
|
||||
|
||||
@render_to('entries/entry.html')
|
||||
def entry(request, kind, id, slug=None):
|
||||
entry = Entry.objects.get(pk=id)
|
||||
entry = get_object_or_404(Entry, pk=id)
|
||||
if request.path != entry.url:
|
||||
return redirect(entry.url, permanent=True)
|
||||
return {
|
||||
|
@ -17,7 +17,7 @@ def entry(request, kind, id, slug=None):
|
|||
|
||||
@render_to('entries/entry_amp.html')
|
||||
def entry_amp(request, kind, id, slug=None):
|
||||
entry = Entry.objects.get(pk=id)
|
||||
entry = get_object_or_404(Entry, pk=id)
|
||||
if request.path != entry.amp_url:
|
||||
return redirect(entry.amp_url, permanent=True)
|
||||
return {'entry': entry}
|
||||
|
|
Loading…
Reference in a new issue