I'm building a To Do list in Django by following a tutorial,
I'm trying to make seperate CSS file instead of directly writing it within HTML file, However i'm recieving 404 error.
Below is directory structure
├─ base/│├─ templates/││└─ base/││├─ login.html││├─ main.html││├─ register.html││├─ style.css││├─ task_confirm_delete.html││├─ task_form.html││├─ task_list.html││└─ task.html│├─ __init__.py│├─ admin.py│├─ apps.py│├─ models.py│├─ tests.py│├─ urls.py│└─ views.py├─ simpletodo/│├─ __init__.py│├─ asgi.py│├─ settings.py│├─ urls.py│└─ wsgi.py├─ venv/├─ db.sqlite3└─ manage.pyBelow are files where I'm strying to include css file
- main.html
<head><meta charset="UTF-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><title>To Do List</title><link rel="stylesheet" href="style.css"></head><body><div class="container"><!-- elements from other pages will go here --> {% block content %} {% endblock content %}</div></body>- task_list.html
{% extends 'base/main.html' %} {% block content %} ** some code **{% endblock content %}Only static i've declared is as below
- settings.py
STATIC_URL = 'static/'Follow up - How do I include other files like scripts in a seperate files as well ?
Following other answers i've triedmaking a static folder and include css file in that
base/│├── static/│└── base/│└── style.css│├── templates/│└── base/STATICFILES_DIRS = [ os.path.join(BASE_DIR, 'base/static'),]