1

I'm currently training in the Django framework and am attaching a CSS document to an HTML document.

All pretty straight forward staff.

Except it apparently isn't. Hardly surprising really.

Can anyone clear this up for me as to why my server not seeing the static CSS file despite correctly pointing Django in the correct directory?

In the settings I have the following config:

STATIC_URL = 'static/'

STATICFILES_DIRS = [
  BASE_DIR / 'static',
  BASE_DIR / '<APP NAME>/static',
]

At the top of the HTML document, I have the following setup. The {% block header %} is in the <header> tag of the base.html document.

{% extends 'base.html' %}
{% load static %}
{% block header %}
<link rel="stylesheet" href="{% static 'main.css' %}">
{% endblock %}

The static folder is located in ROOT / <APP NAME> / static / main.css

So how come the server is not picking up the static folder when it really should be?

Many thanks.

1
  • I had pretty much the same problem and setup as you. I pulled the static files from the server and they were not seen. It worked after I restarted the development server. Commented Dec 18, 2023 at 19:54

0

You must log in to answer this question.

Browse other questions tagged .