Saturday, January 30, 2016

Re: self.publish.strftime('%m')

You could use self.public.strftime('%Y') without any problems here.  If fact, it might be a bit safer if the year is ever less then four digits.  Since month and day are exactly two digits in the URL, reverse has to make sure they match exactly.  That means making sure there is a leading zero.  With the year, you don't have to worry about that, so it gets skipped.

On Jan 26, 2016, at 6:30 AM, 林攀 <18610710105@163.com> wrote:

return reverse('blog:post_detail', args=[self.publish.year,
self.publish.strftime('%m'),
self.publish.strftime('%d'),
self.slug])
url(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<post>[-\w]+)/$',
views.post_detail, name='post_detail'),

i feel confused why publish.year(type int) don't use strftime method .


Peter of the Norse



No comments:

Post a Comment