Check Your path again,
If it's correct
Follow the Guidelines to Include CSS in Django Project
Static files are intended to wrap CSS files and your images, Django automatically identifies this file.
- Create
staticfolder in yourappfolder, same directory as of migrations and template folder - Create
cssFolder and insert it into static Folder - Now put your
styles.cssintocssfolder - Now in your HTML File where you want to include CSS, add
{% load static %}On the top of HTML File and Your Path should be like this<link rel="stylesheet" href="{% static 'css/styles.css' %}">in HTML file. Then Make Change To Your settings.py in projectfoldername with-
STATIC_URL = '/static/'
STATICFILES_DIRS = [ os.path.join(BASE_DIR,'static') ]
STATIC_ROOT = os.path.join(BASE_DIR, 'assets')
Then Run this command
python manage.py collectstatic
You static file will be copied to New file created by django as assets.
If it does not reflect changes Refer here If it does not work
Answer from Prabhat Singh on Stack OverflowCheck Your path again,
If it's correct
Follow the Guidelines to Include CSS in Django Project
Static files are intended to wrap CSS files and your images, Django automatically identifies this file.
- Create
staticfolder in yourappfolder, same directory as of migrations and template folder - Create
cssFolder and insert it into static Folder - Now put your
styles.cssintocssfolder - Now in your HTML File where you want to include CSS, add
{% load static %}On the top of HTML File and Your Path should be like this<link rel="stylesheet" href="{% static 'css/styles.css' %}">in HTML file. Then Make Change To Your settings.py in projectfoldername with-
STATIC_URL = '/static/'
STATICFILES_DIRS = [ os.path.join(BASE_DIR,'static') ]
STATIC_ROOT = os.path.join(BASE_DIR, 'assets')
Then Run this command
python manage.py collectstatic
You static file will be copied to New file created by django as assets.
If it does not reflect changes Refer here If it does not work
According to the official statement "Generally, the templates folder is created and kept in the sample directory where manage.py lives. This templates folder contains all the templates you will create in different Django Apps."
As a Django projects grow in size it's often more convenient to have all the templates in one place rather than hunting for them within multiple apps.
Just as an additional information for the accepted answer's 1."Statement"
Besides, yes you should have your static folder at App-level and it should work!.
python - Not Found: /style.css/ , django - Stack Overflow
python - Django style.css is not found - Stack Overflow
CSS is not working (Django Basics)
Why is django not finding my css file?
Is your file style.css or index.css?
I didn't look through your whole github repo but I did find index.css
Edit: found style.css in accounts. I'm on mobile but it may be a name space issue with 2 folders named static. Wish I could help more, just my best guess.
More on reddit.comVideos
Easy fix, but you will need to dig into Django a bit more.
First, this tag <link rel="stylesheet" href=style.css/> will never work. The tag is written wrong on a few levels. The big problem is that the location is relative, the use of style.css is assumed to be on the same directory level as what ever page/script/etc is being called. The problem is that wsgi.py or similar file is actually the "root" that is "running" the site and has no idea where "style.css" exists and also deos not care.
Styles, image, js, etc are all stored as static assets in Django. This folder is "served" using a static tag that will transform to the correct path per your configuration for local dev and production. Take a look here: https://docs.djangoproject.com/en/3.1/howto/static-files/
I will not explain all the nuance, the Django site does a better job. Instead I will point out how Django is different from static sites or something like PHP. Django is an application running in the CGI (WSGI), there is only one "route" on the server so to speak, all data is served from this one file. PHP can and typically does serve data in a file+directory manner. In PHP/static scenario the location of files is stable compared to Django. In Django the page, url, and the way data is served all come from one point. That means the relationship to static files will be different and not something you can or should control.
Django does not want you to ever serve static files through the CGI (WSGI), that is a waste of CPU and resources and is slow for static. So they have a static system. When running locally with the configuration set up correctly and DEBUG=True then the static keyword will transform to the necessary local path in conjunction with your configuration.
When in production it is assumed that a CDN is used, in that case the static keyword is replaced with the path (URL) to the CDN static files.
The approach Django uses is much more mature than say, Wordpress where use of a CDN can be tricky (I have written custom CDNs for WP many times, not fun).
Walk through the link above, set up your configuration correctly and follow the rules. Django is very interested in your following of the rules, Deviation will only cause pain. I have been primarily a Django dev for almost 10 years now. The problem you ran into got me real good in the beginning, but now CDN and static file management is second nature and definitely more productive than other less mature systems.
Set static root on your 'settings.py'.
According Django's documentation, I added this to my settings dot py file:
STATIC_URL = 'static/'
STATICFILES_DIRS = [
BASE_DIR / "static",
]
Then, my home page looks like this:
{% load static %}
<!DOCTYPE html>
<html class="wide wow-animation" lang="en"> <head> <!-- Site Title--> <title>Home</title> <meta name="format-detection" content="telephone=no"> <meta name="viewport" content="width=device-width, height=device-height, initial-scale=1.0, maximum-scale=1.0, user-scalable=0"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta charset="utf-8"> <link rel="icon" href="{% static 'website/images/favicon.ico' %}" type="image/x-icon">
(Note: I'm just showing the upper side of the page)
But on that page, I just see the text /static/website/images/favicon.ico, the icon is not loading.
I've been dealing with this for hours, could not find any solution, can somebody help me, please?
For Django to serve static files, you have to make sure you have a couple of settings.
STATIC_URL
This setting specifies what URL should static files map to under. You have that done already.
STATICFILES_DIRS
This specifies all the folders on your system where Django should look for static files. The idea is that you might have a couple of apps within your project, and each app might require a different set of static files. So for organizational purposes, each app might contain a static directory where it will store only its static files. So then Django has to have a way to know where those directories are. This is what this setting is for.
STATIC_ROOT
This setting specifies where Django will copy all the static files to and not where the static files are already at. The idea is that once you leave development into production, Django can't serve static files anymore due to issues I will not go here (it's in the article). However, for production, all static files should be in a single directory, instead of in many like specified in STATICFILES_DIRS. So this setting specifies a directory to which Django will copy all the static files from all files within STATICFILES_DIRS by running the following command:
$ python manage.py collectstatic
Please note this is only necessary once you go into production and also that the directory specified here cannot be the same as any directory specified in STATICFILES_DIRS.
Urls.py
In development for Django to serve your static files, you have to include the static URLs in your urls.py:
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns = ...
urlpatterns += staticfiles_urlpatterns()
Once you will complete all of the above things, your static files should be served as long as you have DEBUG = True. Out of the list above, you seem to only complete STATIC_URL. Also please note that all the steps I described above are in the docs you linked in your question (link). It might be a bit confusing in the beginning but if you read it a couple of times, it becomes clearer.
Try clearing your cache. If you are using Google chrome go to your settings>clear browsing data> select clear cached images and files then click clear data