Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Django : Is it impossible to static tag into block tag?

The code below makes error.. How could I resolve this problem?

{% block header %}     <link rel="stylesheet" href="{% static 'shop/style.css' %}" /> {% endblock %} 

The error output:

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

like image 764
nextdoordoc Avatar asked Mar 26 '14 02:03

nextdoordoc


People also ask

What does {% load static %} do in Django?

The very first line in the file, {% load static %} , uses Django's special template tag syntax to tell the template engine to use the files in the static folder in this template.

What is use of static files in Django?

django. contrib. staticfiles collects static files from each of your applications (and any other places you specify) into a single location that can easily be served in production. For an introduction to the static files app and some usage examples, see How to manage static files (e.g. images, JavaScript, CSS).

Is Django static?

Local Development. For local development the Django web server automatically serves static files and minimal configuration is required. A single Django project often contains multiple apps and by default Django will look within each app for a static directory containing static files.


1 Answers

No, it is not impossible. Try including {% load staticfiles%} in the same html file, rather than attempting to inherit it from some base.html.

like image 52
David C Avatar answered Oct 21 '22 07:10

David C