Hello,
I’m writing a Blog app with the help of a book.
I have this in my urls.py
:
path('<int:year>/<int:month>/<int:day><slug:post>/', views.post_detail, name='post_detail'),
and in the models.py
this function generates the link to each blog post:
def get_absolute_url(self):
return reverse('blog:post_detail', args=[self.publish.year, self.publish.month, self.publish.day, self.slug])
However, the link is generated like “2020/12/9slug” not “2020/12/9/slug”.
As far as I know, the reverse
function should add the trailing slash “/” automatically. but somehow it’s not happening.
How to fix this?