Tango with Django, Chapter 11: Could not parse the remainder: ' static' from 'load static'

StackOverflow https://stackoverflow.com/questions/23664240

  •  22-07-2023
  •  | 
  •  

Domanda

Here's the full error message:

Could not parse the remainder: ' static' from 'load static':

1   {% extends 'rango/base.html' %}   <===This line is highlighted
2   {% load static %}
3   
4   {% block body_block %}
5   <div class="hero-unit">
6   
7   {% if user.is_authenticated %}
8     <h1>Rango says...hello {{ user.username }}.</h1>
9   {% else %}
10    <h1>Rango says...hello world.</h1>
11  {% endif %}

This page, index.html, used to work, but in Chapter 11 the book has the reader add Bootstrap to the html, and after setting up base.html with the proper classes, this page no longer works. base.html also has the line:

{% load static %}

but deleting the same line from index.html above produces another error(with line 33 highlighted):

Invalid block tag: 'static', expected 'endblock'

23    <h3>Most Viewed Pages:</h3>
24    {% if pages %}
25    <ul>
26      {% for page in pages %}
27      <li><a href="{{ page.url }}">{{ page.title }} ({{ page.view_count }})</a></li>
28      {% endfor %}
29    {% else %}
30    <strong>No pages have been rangoed yet.</strong>
31    {% endif %}
32        
33    <div><img src="{% static 'rango.jpg' %}" alt="Picture of Rango" /></div>
34  
35  </div>
36  
37  {% endblock %}

base.html:

<!DOCTYPE html>
{{ load static }}
<html>
...
...
È stato utile?

Soluzione

!#$!@#$!@#. Arggh. In base.html, it should be:

{% load static %}

not:

{{ load static }}

Altri suggerimenti

basically same problem with me but i deleted the line and written again word by word and now its working. { {% load static %} }

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top