Simplify entry routing by using one route with an optional slug for permalinks, rather than a route with a slug and a route without
This commit is contained in:
parent
1f6a587329
commit
5987e54105
3 changed files with 7 additions and 15 deletions
|
|
@ -88,12 +88,10 @@ class Entry(ModelMeta, models.Model):
|
|||
@property
|
||||
def url(self):
|
||||
kind = kinds.from_id[self.kind]
|
||||
route = kind.entry
|
||||
args = [self.id]
|
||||
if kind.slug:
|
||||
route = kind.entry_slug
|
||||
args.append(self.slug)
|
||||
return reverse('entries:' + route, args=args)
|
||||
return reverse('entries:' + kind.entry, args=args)
|
||||
|
||||
@property
|
||||
def slug(self):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue