it works well .thanks .




--

林攀

在 2016-01-31 02:57:19,"Peter of the Norse" <rahmc...@radio1190.org> 写道:

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, 林攀 <18610710...@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
rahmc...@radio1190.org







--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9C959670-19AE-48A3-97E7-A8C99E4A8A6B%40Radio1190.org.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/4689fd21.1e8a.15297af94bb.Coremail.18610710105%40163.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to