Search code examples
pythondjangodjango-staticfiles

Invalid block tag on line 10: 'static'/css/all.css''. Did you forget to register or load this tag?


am getting Invalid block tag on line 10: 'static'/css/all.css''. Did you forget to register or load this tag? when i run my django app. here is my code:

{% load static %}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <!-- Font Awesome -->
    <link rel="stylesheet" href="{% static'/css/all.css'%}">
    <!-- Bootstrap -->
    <link rel="stylesheet" href="{% static'/css/bootstrap.css'%}">
    <!-- Custom -->
    <link rel="stylesheet" href="{% static'/css/style.css'%}">

    <title>BT Real Estate</title>
</head>

here is my static settings

STATIC_ROOT= os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = [`enter code here`
    os.path.join(BASE_DIR, 'btre/static')
]

Solution

  • This is due to spacing in {% static'/css/all.css'%} the above comment by @ Abdul Aziz Barkat is correct.

    Try this:

    {% load static %}
    <!DOCTYPE html>
    <html lang="en">
    
    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <!-- Font Awesome -->
        <link rel="stylesheet" href="{% static 'css/all.css' %}">
        <!-- Bootstrap -->
        <link rel="stylesheet" href="{% static 'css/bootstrap.css' %}">
        <!-- Custom -->
        <link rel="stylesheet" href="{% static 'css/style.css' %}">
    
        <title>BT Real Estate</title>
    </head>