Hannon qaoud
Hannon qaoud

Reputation: 958

Loading css from static files in django not working

This is what the file explorer looks like:

this is what the file explorer looks like

this is the html file

userController/templates/users/dashboard.html

{% extends 'base.html' %}
{% load static %}
<html>
    <head>
        /* loadint the css */
        <link rel="stylesheet" href="{% static 'css/dashboard.css' %}">

demowebsite/settings.py

# STATIC_DIR=os.path.join(BASE_DIR,'static')
STATICFILES_DIRS = [
   os.path.join(BASE_DIR, 'userController/static/')
]
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static')

the css file is not getting loaded, i cant tell where my problem is

Upvotes: 0

Views: 41

Answers (1)

Mohammadreza Nazif
Mohammadreza Nazif

Reputation: 11

the structure of your static files should be like below , change your code like this

STATIC_URL = "static/"
STATICFILES_DIRS = [
   os.path.join(BASE_DIR,"static")
]

Upvotes: 1

Related Questions