# Django can't find my static files despite all the right settings...

**URL:** <https://forum.djangoproject.com/t/django-cant-find-my-static-files-despite-all-the-right-settings/11273>\
**Category:** Using Django\
**Created:** [December 29, 2021, 1:11am UTC](https://forum.djangoproject.com/t/django-cant-find-my-static-files-despite-all-the-right-settings/11273 "2021-12-29T01:11:43Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![enjoysmath](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/enjoysmath/32/5923_2.png) [@enjoysmath](https://forum.djangoproject.com/u/enjoysmath)\
**Post date:** [December 29, 2021, 1:11am UTC](https://forum.djangoproject.com/t/django-cant-find-my-static-files-despite-all-the-right-settings/11273/1 "2021-12-29T01:11:43Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/0/05d05ef7f98c0f655b78c9d48349280b240ec725.png)

There is an image of what my browser sees and also showing the project structure on the left.

My corresponding `settings.py` reads:

```auto
"""
Django settings for abstract_spacecraft project.

Generated by 'django-admin startproject' using Django 3.1.5.

For more information on this file, see
https://docs.djangoproject.com/en/3.1/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/3.1/ref/settings/
"""

from pathlib import Path
import os

# Build paths inside the project like this: BASE_DIR / 'subdir'.
BASE_DIR = Path( __file__ ).resolve().parent.parent
SITE_ROOT = os.path.dirname(os.path.realpath( __file__ ))
SETTINGS_PATH = os.path.dirname(os.path.dirname( __file__ ))

# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/3.1/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = '=p_lram126h4^=5e80@h3)c_&%xebx_3)wx1@o3t$o0mi-4m%x'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = []

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'accounts.apps.AccountsConfig',
]

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    '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',
]

ROOT_URLCONF = 'abstract_spacecraft.urls'

TEMPLATES_PATH = os.path.join(SETTINGS_PATH, 'templates')

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [TEMPLATES_PATH, 
                 os.path.join(TEMPLATES_PATH, 'accounts')],
        'APP_DIRS': True,
        'OPTIONS': {
            'debug': True,
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'abstract_spacecraft.wsgi.application'

# Database
# https://docs.djangoproject.com/en/3.1/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': BASE_DIR / 'db.sqlite3',
    }
}

# Password validation
# https://docs.djangoproject.com/en/3.1/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]

# Internationalization
# https://docs.djangoproject.com/en/3.1/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

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

STATIC_URL = '/static/'

STATICFILES_DIRS = (
  os.path.join(SITE_ROOT, 'static/'),
)

```

* * *

So how do I force Django to see my static files? It seems that although Django is supposed to work well / nicely with its templating system, I can never get it to find the templates properly (without having to write in the app dir to the template dirs in `settings.py`), nor can I get it to find the static files. I’ve done nothing to this boilerplate project (generated by WingWare), except add an `accounts` app. I’m trying to get BSS to export to Django, and I can modify where the static files get sent to. I just need help getting Django to know where they are. Where’s the best place to put them and why the heck can’t Django just work out-of-the-box. This is annoying as a developer.

---

<div class="post-metadata">

**Author:** ![enjoysmath](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/enjoysmath/32/5923_2.png) [@enjoysmath](https://forum.djangoproject.com/u/enjoysmath)\
**Post date:** [December 29, 2021, 1:35am UTC](https://forum.djangoproject.com/t/django-cant-find-my-static-files-despite-all-the-right-settings/11273/2 "2021-12-29T01:35:15Z")

</div>

Okay, I did some debugging and found that if I do:

```auto
SITE_ROOT = os.path.dirname(os.path.dirname(os.path.realpath( __file__ )))
STATICFILES_DIRS = (
  os.path.join(SITE_ROOT, 'static/'),
)

```

i.e. two iterates of `dirname()` in `settings.py` my browser errors are partially taken care of. So that was the solution, just to debug it myself 🙂

 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/4/48753f6b98c336014f9b4cf06a94c6dada8206b6.png)
