﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
34702	Runserver serving static files from STATICFILES_DIRS instead of STATIC_ROOT	Ryan Moscoe	nobody	"This is my first Django project, so I apologize if this turns out not to be a bug--but I've done a lot of searching on Google, in the Django docs, and in the FAQ, and I am confident this is a bug. When I run collectstatic, my static files are correctly copied from the STATICFILES_DIRS directory to the STATIC_ROOT directory. However, when I run runserver, the static files are served from the STATICFILES_DIRS directory. 

I am attempting to serve a React front end with a Django back end, so I have run the build on the client side to generate static files for Django to serve. However, I was getting MIME Type errors for my CSS and JS files, despite getting a status code of 200 for them. In an attempt to resolve this issue, I changed the href and src attributes for the <link> and <script> tags in my index.html file in the STATIC_ROOT directory. However, I noticed that runserver was still looking for the CSS and JS files in the same place, which made me suspicious.

With runserver still running, I started altering the href and src attributes for my <link> and <script> tags in my STATICFILES_DIRS directory (client/dist), and I saw the changes take effect in real time. The relevent settings in my settings.py file appear below:

{{{
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'server.apps.ServerConfig',
    'rest_framework',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'whitenoise.middleware.WhiteNoiseMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

STATIC_URL = '/static/'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'client', 'dist')]
}}}"	Bug	closed	contrib.staticfiles	4.2	Normal	invalid	runserver, staticfiles		Unreviewed	0	0	0	0	0	0
