[Answered ]-Django css static not load

2👍

This as per document,you can try like this

settings.py

STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
'/var/www/static/',# Here you can mention your static directory
]

urls.py

from django.conf import settings
from django.conf.urls.static import static


urlpatterns = [
# ... the rest of your URLconf goes here ...
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

in your template

{% load static %}
<img src="{% static "my_app/example.jpg" %}" alt="My image"/>

Store your static files in a folder called static in your app. For example my_app/static/my_app/example.jpg.

👤Robert

0👍

Try this in settings.py also:

STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static"),
]
👤Zollie

Leave a comment