Currently have a folder structure set up in django:
{appname}\templates\
{appname}\templates\assets\css\
but when I try to include something like <link rel="stylesheet" href="assets/css/bootstrap.css" />
in my templates in {appname}\templates\
, it's not loading for whatever reason; I can load directly from twitter, but I'd prefer to keep relative paths if possible.
Why might this not work? If it's any clue, the subfolders in PyCharm are appearing as light grey, not sure why that is happening either.
edit: okay so I read up here on how to set up static files, and have set up a static
directory under my main project folder, with a css
folder underneath that.
I updated settings.py to include:
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Additional locations of static files
import os.path
STATICFILES_DIRS = (
os.path.dirname(__file__).replace('\\','/'),
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
and then attempted to add
<link rel="stylesheet" href="{{ STATIC_URL }}css/bootstrap.css" />
to my html file, but it's not loading -- what am I doing wrong here?