I'm working on a Django(2.1.7) project in which I need to load some images in css file. Here's what I have so far:
From settings.py:
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
STATIC_URL = '/assets/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'assets'), ]
I have a directory in my main project folder named as assets and also have 'django.contrib.staticfiles' in INSTALLED_APPS and then I have mentioned some images in css as:
background: url('/assets/images/demo.png') center no-repeat;
The image is available in the images folder but not displaying in the template.
What can be wrong here?
{% load static %}at the beginning of your template?cssfile where{% load static %}doesn't work and template is working.imagesfolder inside myassetsfolder`.