简体   繁体   中英

CSS file not loading (Django, python)

Here's the code I have:

In the HTML file:

<link rel="stylesheet" href={% static 'css.css' %}" >

In settings.py:

 STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)

The css.css file is located in the static directory which is in the same directory as manage.py , So why isn't the css file loading?

There is also a js file which doesn't seem to be loading either, and it's in the same directory as the CSS file and I'm loading it in with the same method as the CSS file.

Also, my pc isn't currently connected to WiFi, in case it makes a difference. I'm working with localhost.

Have you configured your Static files URL. According to best practice

STATIC_URL = '/static/'

Actually the above is too little information to help anyway. Can you tell us the application environment (production/development) etc because there are specific configurations for each in Django. Also please provide code using the code markup. Assuming you are using Django 1.11, read this for a better understanding or better yet see a tutorial for beginners

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM