static files in python using css

Viewed 39
<html>
    <head>
        <title>
        <link rel="stylesheet" href="//maxcdn.bootstrap.com/bootstrap/3.2.0/css/bootstrap.min.css">
        <link rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap-theme.min.css">
        <link rel="stylesheet" href={% static 'css/blog.css' %}">
        <link href="//fonts.googleapis.com/css?family=Lobster&subset=latin,latin-ext" rel="stylesheet" type="text/css">
    </head>
    <body>
        <div>
            <h1><a href=" ">Cradle's Blog</a></h1>
        </div>
        {{ % for post in posts }}
            <div>
                <p> published: {{ post.published_date }}</p>
                <h1><a href=" ">{{ post.title }}</a></h1>
                <p>{{ post.text|linebreaksbr }}</p>
            </div>
        {{% endfor %}}
    </body>
</html>

the error I'm getting states; Invalid block tag on line 6: 'static'. Did you forget to register or load this tag?... how do I perform this action? I'm getting a new error saying: could not parse the remainder. '%for post in posts %' from '% for post in posts %'

1 Answers

You need to load the static template tags/filters [Django-doc] first, so:

{% load static %}
<html>
    …
</html>

Furthermore a template tag is written between {% … %}, not {{% … %}}. You thus should implement this with:

{% for post in posts %}
    …
{% endfor %}
Related