Switch home.urls and entries.urls over to modern path() definitions, with param conversion and such

This commit is contained in:
Danielle McLean 2018-05-04 12:13:52 +10:00
parent 0b43aad50e
commit e9c46f23db
Signed by: 00dani
GPG key ID: 8EB789DDF3ABD240
8 changed files with 60 additions and 31 deletions

View file

@ -1,14 +1,12 @@
from annoying.decorators import render_to
from django.shortcuts import get_object_or_404
from django.urls import reverse
from .. import kinds
from ..models import Entry, Cat
from ..pagination import paginate
@render_to('entries/index.html')
def by_kind(request, kind, page):
kind = kinds.from_plural[kind]
def by_kind(request, kind, page=None):
entries = Entry.objects.filter(kind=kind.id)
entries = paginate(queryset=entries, reverse=kind.index_page, page=page)
if hasattr(entries, 'content'):
@ -23,7 +21,7 @@ def by_kind(request, kind, page):
@render_to('entries/index.html')
def by_cat(request, slug, page):
def by_cat(request, slug, page=None):
def url(page):
kwargs = {'slug': slug}
if page > 1: