I'm creating a blog post and after migrating my blog files successfully I am returned an error when I go to the blog page of my website ( Could not parse the remainder: ': "Y-m-d"' from 'post.date|date: "Y-m-d"')
I cant seem to find whether this is a syntax error or a logic error
HTML:
{% extends "personal/header.html" %}
{% block content %}
{% for post in object_list %}
<h5> {{ post.date|date: "Y-m-d"}} <a href="/blog/{{ post.id }}"> {{ post.title }} </a> </h5>
{% endfor %}
{% endblock %}
Python (models.py):
from django.db import models
class Post (models.Model):
title = models.CharField(max_length=140)
body = models.TextField()
date = models.DateTimeField()
def __unicode__(self):
return self.title
You need to remove the space after the colon:
{{ post.date|date:"Y-m-d" }}
there should be no space between colon (:) and date and date format eg. date:"d-m-Y"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With