1👍
✅
Django 1.4+
{% static %}
<link rel="stylesheet" type="text/css" href="{% static 'css/index.css' %}"/>
Note: If this code is not working, you should check your settings and urlconf. And I also notice some bad practice in your codes.
0👍
You can try another way :
Edit these variables in the file settings.py
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
STATIC_URL = os.path.join(PROJECT_URL, 'static')
They are refering to absolute path to folders on your system, for example :
- PROJECT_ROOT –> /home/user/project
- STATIC_URL –> /home/user/project/static
Expand url from STATIC_URL variables :
- {{ STATIC_URL }} –> h ttp://(your_host)/static/
- {{ STATIC_URL }}/css –> h ttp://(your_host)/static/css
- [Answer]-Cookie does not show up in Chrome Developer Tools (Django Python)
- [Answer]-Select_related or select_prefetched after calling filter()?
- [Answer]-Sending data to an external server in django
Source:stackexchange.com