Use reverse URL generation for detail view
This commit is contained in:
parent
293350658a
commit
7fa679f795
2 changed files with 12 additions and 5 deletions
|
@ -18,6 +18,7 @@
|
|||
#
|
||||
from django.db import models
|
||||
from django.conf import settings
|
||||
from django.urls import reverse
|
||||
#from podjango.apps.staff.models import Person
|
||||
from datetime import datetime, timedelta
|
||||
|
||||
|
@ -34,7 +35,7 @@ class CastTag(models.Model):
|
|||
return self.label
|
||||
|
||||
def get_absolute_url(self):
|
||||
return "/cast/?tag=%s" % self.slug
|
||||
return reverse('podjango:cast') + "?tag=%s" % self.slug
|
||||
|
||||
class Cast(models.Model):
|
||||
"""Cast"""
|
||||
|
@ -66,10 +67,15 @@ class Cast(models.Model):
|
|||
return self.title
|
||||
|
||||
def get_absolute_url(self):
|
||||
return "/cast/%s/%s/" % (self.pub_date.strftime("%Y/%b/%d").lower(),
|
||||
self.slug)
|
||||
# FIXME
|
||||
# return (u"/cast/%s/" % (self.slug))
|
||||
return reverse(
|
||||
'podjango:detail',
|
||||
kwargs={
|
||||
'year': self.pub_date.year,
|
||||
'month': self.pub_date.strftime("%b").lower(),
|
||||
'day': self.pub_date.day,
|
||||
'slug': self.slug,
|
||||
}
|
||||
)
|
||||
|
||||
def is_recent(self):
|
||||
return self.pub_date > (datetime.now() - timedelta(days=14))
|
||||
|
|
|
@ -17,6 +17,7 @@
|
|||
# "AGPLv3". If not, see <http://www.gnu.org/licenses/>.
|
||||
#
|
||||
from datetime import datetime
|
||||
from functools import reduce
|
||||
|
||||
from django.views.generic.list import ListView
|
||||
from django.shortcuts import get_object_or_404, render
|
||||
|
|
Loading…
Reference in a new issue