Django error: Could not parse remainder: ': "Ymd"' from 'post.date | date: "Ymd" '

I am creating a blog post and after successfully migrating my blog files. I come back with an error when I go to the blog page of my site (couldn't parse the remainder: ': "Ymd"' from 'post.date | date: "Ymd"')

I can't seem to find if this is a syntax error or a logical 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

      

+3


source to share


1 answer


You need to remove the space after the colon:



{{ post.date|date:"Y-m-d" }}

      

+3


source







All Articles