4

I have a datetime object at my model. I am sending it to the view, but in html i don't know what to write in order to format it.

I am trying

{{ item.date.strftime("%Y-%m-%d")|escape }}

but I get

TemplateSyntaxError: Could not parse some characters: item.date.strftime|("%Y-%m-%d")||escape

when I am just using

{{ item.date|escape }}

it's working, but now with the format I want.

Any suggestions?

1 Answer 1

11

Try using the built-in Django date format filter instead:

{{ item.date|date:"Y M d" }}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.