17👍
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
static
folder in yourapp
folder, same directory as of migrations and template folder - Create
css
Folder and insert it into static Folder - Now put your
styles.css
intocss
folder - 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
1👍
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!.
- [Django]-Can we pass array/list to template content blocks in django? python
- [Django]-Humanize in django/python, how to translate
- [Django]-Django model TimeField views.py cannot select hour or minute