0

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

9
  • docs.djangoproject.com/en/4.1/howto/static-files/… Commented Aug 24, 2022 at 9:08
  • open dev console on browser click to network refresh the page see 404 no found and click on it you will see details(response tab) like the file couldn't find and you will also see a URL that Django try to get the file from copy it and go to this URL to be sure that your file in this URL Commented Aug 24, 2022 at 9:09
  • I've read this and many other sources many times, i came here after along and exhausting research. Commented Aug 24, 2022 at 9:12
  • @enesislam its css it doesnt raise an error Commented Aug 24, 2022 at 9:14
  • @Hannonqaoud could you access your css file on the new tab? Commented Aug 24, 2022 at 9:15

1 Answer 1

1

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")
]
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.