How to change the default Django date template format

0 votes
I have dates in ISO 8601 format in the database, %Y-%m-%d. However, when the date is passed on to the template, it comes out as something like Oct. 16, 2011.

Is there a way that I can manipulate the format to whatever I want?
Aug 7, 2020 in Python by kartik
• 37,520 points
4,329 views

1 answer to this question.

0 votes

Hello @kartik,

Within your template, you can use Django's date filter. E.g.:

<p>Birthday: {{ birthday|date:"M d, Y" }}</p>

Gives:

Birthday: Mar 05, 1998

hope this helps!!
Thank you!!

answered Aug 7, 2020 by Niroj
• 82,880 points

Related Questions In Python

0 votes
1 answer
0 votes
1 answer

How to access the user profile in a Django template?

Hello @kartik, In your profile model provide related_name user ...READ MORE

answered Jul 29, 2020 in Python by Niroj
• 82,880 points
5,887 views
–1 vote
1 answer

How to get the current URL within a Django template?

Hello @kartik, You can fetch the URL in ...READ MORE

answered Aug 6, 2020 in Python by Niroj
• 82,880 points
8,411 views
0 votes
1 answer

How can I change the data type to string in Python?

You can use str(variablename) This is called conversion ...READ MORE

answered Dec 18, 2018 in Python by Shuvodip
900 views
0 votes
1 answer

How to temporarily disable a foreign key constraint in MySQL?

Hello @kartik, To turn off foreign key constraint ...READ MORE

answered Jun 23, 2020 in Python by Niroj
• 82,880 points
2,330 views
0 votes
1 answer

How do I use Django templates without the rest of Django?

Hello @kartik, Let's say you have this important ...READ MORE

answered Jun 23, 2020 in Python by Niroj
• 82,880 points
1,481 views
0 votes
1 answer

How to update date automatically after a value change in django?

Hello @kartik, Only change your pub_date if published has ...READ MORE

answered Jul 3, 2020 in Python by Niroj
• 82,880 points
9,559 views
0 votes
1 answer

How to change the file name of an uploaded file in Django?

Hello @kartik, The basic way is import os os.rename('a.txt', 'b.html') For ...READ MORE

answered Jul 3, 2020 in Python by Niroj
• 82,880 points
4,521 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP