[Answered ]-Django stylesheet will not load

2👍

✅

You should remove the entry in your urls.py. All I required to serve static files is the following:

in my settings.py:

DEBUG = True

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
)

MIDDLEWARE_CLASSES = (
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
STATICFILES_DIRS = (
    os.path.join(BASE_DIR, 'myprojectname/static'),
)

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/

STATIC_URL = '/static/'

In my template:

{% load staticfiles %}

<script type="text/javascript" src="{% static 'raphael-min.js' %}"></script>

The file’s location is ./myprojectname/static/raphael-min.js IE /home/username/djangoProjects/myprojectname/myprojectname/static/raphael-min.js

Leave a comment