lemoncurry/entries/views/perma.py

15 lines
404 B
Python
Raw Normal View History

from annoying.decorators import render_to
from django.shortcuts import redirect, get_object_or_404
from ..models import Entry
2023-08-10 02:52:37 -04:00
@render_to("entries/entry.html")
def entry(request, kind, id, slug=None):
entry = get_object_or_404(Entry, pk=id)
if request.path != entry.url:
return redirect(entry.url, permanent=True)
return {
2023-08-10 02:52:37 -04:00
"entry": entry,
"title": entry.title,
}