1
Paths inside of your CSS file are relative, so you don’t need to set static at all in the CSS file.
For example:
Your stylesheet is located at /home/user/domains/domain/public_html/website/website/static/stylesheet.css
Assuming your file structure is:
-- /static
-- -- stylesheet.css
-- -- -- /img
-- -- -- -- body.png
You can simply define your body as:
body {
background: url('img/body.png');
padding-top: 20px;
padding-bottom: 40px;
font-family: Georgia,"Bitstream Charter",serif;
}
And call your stylesheet in your HTML via:
<link rel="stylesheet" type="text/css" href="{{ STATIC_ROOT }}stylesheet.css">
0
Your STATIC_URL
should be a url (i.e. static.yourdomain.com/your_application/
or similar), that looks like a path on your filesystem so it won’t work.
Normally a relative url in your css files should work just fine.
And don’t forget to run manage.py collectstatic
: https://docs.djangoproject.com/en/dev/ref/contrib/staticfiles/#collectstatic
- [Answer]-Django is serving static css files, yet somehow js files show a 404
- [Answer]-Django foreignkey query
- [Answer]-Django Hide Processing Page
Source:stackexchange.com