Tuesday, January 26, 2016

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



On Tue, Jan 26, 2016 at 5: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 .

publish.year is probably an integer (or a property that returns an integer), not a datetime object, hence it doesn't support the .strftime() method. Without the model/object definition, I couldn't say for sure, though.

You can probably substitute it with self.publish.strftime('%Y') if it makes you feel better.

-James

--
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+unsubscribe@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/CA%2Be%2BciWvN7RJS0rZcnrxn0%2BdkynfEjFqQzsN-X8rZkAai1qA9Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment