I would like to know how to merge months and years when displaying a date in a Django template.
From this:
Oct. 12, 2012 - Oct. 20, 2012
To this:
Oct. 12-20, 2012
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Something like this should work. It makes sure that the month and year are the same, in which case outputs string like
Oct. 12-20, 2012. If not, then it outputsOct. 12, 2012 - Oct. 22, 2013.Here is a full reference for Django
datetemplate filter.