# my static file not found

**URL:** https://forum.djangoproject.com/t/my-static-file-not-found/11474
**Category:** Using Django
**Created:** [January 10, 2022, 5:45am UTC](https://forum.djangoproject.com/t/my-static-file-not-found/11474 "2022-01-10T05:45:31Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![yudeqang](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/yudeqang/32/6995_2.png) [@yudeqang](https://forum.djangoproject.com/u/yudeqang)
#### Post date: [January 10, 2022, 5:45am UTC](https://forum.djangoproject.com/t/my-static-file-not-found/11474/1 "2022-01-10T05:45:31Z")

</div>

My settings.py:  
STATIC\_URL = ‘/static/’  
STATIC\_ROOT = os.path.join(BASE\_DIR, “static/”)  
INSTALLED\_APPS = [  
…  
‘django.contrib.staticfiles’,  
…  
]

my static folder:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/6/6852973e8facd70c4d33952f3a1d2be3e5a243e0.png)  
When I debug my django app on local host,  
“GET /static/rest\_framework/js/ajax-form.js HTTP/1.1” 404

---

<div class="post-metadata">

### Author: ![CodenameTim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/codenametim/32/31507_2.png) [@CodenameTim](https://forum.djangoproject.com/u/CodenameTim)
#### Post date: [January 10, 2022, 2:43pm UTC](https://forum.djangoproject.com/t/my-static-file-not-found/11474/2 "2022-01-10T14:43:23Z")

</div>

[Do you include the static urls when `settings.DEBUG` is True?](https://docs.djangoproject.com/en/4.0/howto/static-files/#serving-static-files-during-development)

---

<div class="post-metadata">

### Author: ![yudeqang](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/yudeqang/32/6995_2.png) [@yudeqang](https://forum.djangoproject.com/u/yudeqang)
#### Post date: [January 11, 2022, 1:54am UTC](https://forum.djangoproject.com/t/my-static-file-not-found/11474/3 "2022-01-11T01:54:58Z")

</div>

Yes，  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/djangoproject/original/2X/a/a75d26b7186e82b42a2e05a3892e6febcf872fa6.png)  
I set this but it doesn’t work either

---

<div class="post-metadata">

### Author: ![CodenameTim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/codenametim/32/31507_2.png) [@CodenameTim](https://forum.djangoproject.com/u/CodenameTim)
#### Post date: [January 11, 2022, 2:24pm UTC](https://forum.djangoproject.com/t/my-static-file-not-found/11474/4 "2022-01-11T14:24:40Z")

</div>

I’m curious if it matters if you’re using `from drf.settings import STATIC_ROOT` vs `from django.conf import settings`.

Please list all the [static file settings](https://docs.djangoproject.com/en/4.0/ref/settings/#settings-staticfiles) values that you have configured. And are you running this in with `DEBUG = True`?

---

<div class="post-metadata">

### Author: ![yudeqang](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/yudeqang/32/6995_2.png) [@yudeqang](https://forum.djangoproject.com/u/yudeqang)
#### Post date: [January 12, 2022, 1:27am UTC](https://forum.djangoproject.com/t/my-static-file-not-found/11474/5 "2022-01-12T01:27:29Z")

</div>

No,DEBUG=False,  
`from drf.settings import STATIC_ROOT` and `from django.conf import settings` the effect is the same

---

<div class="post-metadata">

### Author: ![yudeqang](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/yudeqang/32/6995_2.png) [@yudeqang](https://forum.djangoproject.com/u/yudeqang)
#### Post date: [January 12, 2022, 1:30am UTC](https://forum.djangoproject.com/t/my-static-file-not-found/11474/6 "2022-01-12T01:30:17Z")

</div>

This is all of my settings.py

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

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

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

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

import os

# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath( __file__ )))
CSV_DIR = os.path.join(BASE_DIR, 'csv_file')
FRUIT_DIR = os.path.join(BASE_DIR, 'fruit_config')
TIF_DIR = os.path.join(BASE_DIR, 'tifs')

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

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'ae@2t(_pj)je@ce8atnbnb)1up$-r_&_r1lz24h)hdxo_#3m1u1'

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

ALLOWED_HOSTS = ['*']
STATIC_ROOT = os.path.join(BASE_DIR, "static/")

# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'rest_framework',
    'corsheaders',
    'api',
    'gntx_api'
]

REST_FRAMEWORK = {
    'DEFAULT_PAGINATION_CLASS': 'api.my_pagination.MyLOPagination',
    'PAGE_SIZE': 100,
    'EXCEPTION_HANDLER': 'api.exception_handler.custom_exception_handler'
}

MIDDLEWARE = [
    'api.middle.UriMiddleware',
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    'django.middleware.common.CommonMiddleware',
    # 'django.middleware.csrf.CsrfViewMiddleware',
    'corsheaders.middleware.CorsMiddleware',
    'django.middleware.common.CommonMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]

ROOT_URLCONF = 'drf.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [os.path.join(BASE_DIR, 'templates')]
        ,
        'APP_DIRS': True,
        'OPTIONS': {
            '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 = 'drf.wsgi.application'

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

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql',
        'NAME': 'farm_gis',
        'USER': 'postgres',
        'PASSWORD': '',
        'HOST': '',
        'PORT': '5432',
    }
}

# Password validation
# https://docs.djangoproject.com/en/3.0/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.0/topics/i18n/

LANGUAGE_CODE = 'zh-cn'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

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

STATIC_URL = '/static/'
CORS_ALLOW_CREDENTIALS = True
CORS_ORIGIN_ALLOW_ALL = True

APPEND_SLASH = False

CORS_ORIGIN_WHITELIST = ()

CORS_ALLOW_METHODS = [
    "DELETE",
    "GET",
    "OPTIONS",
    "PATCH",
    "POST",
    "PUT",
]

CORS_ALLOW_HEADERS = (
    'accept',
    'accept-encoding',
    'authorization',
    'content-type',
    'dnt',
    'origin',
    'user-agent',
    'x-csrftoken',
    'x-requested-with',
)

```

---

<div class="post-metadata">

### Author: ![CodenameTim](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/codenametim/32/31507_2.png) [@CodenameTim](https://forum.djangoproject.com/u/CodenameTim)
#### Post date: [January 13, 2022, 1:37pm UTC](https://forum.djangoproject.com/t/my-static-file-not-found/11474/7 "2022-01-13T13:37:00Z")

</div>

If you’re running this locally, you’re running it with `DEBUG=False` which won’t enable the static files urls.

If you’re running this on production, then you need to find another way to server your static files see the [docs](https://docs.djangoproject.com/en/3.0/howto/static-files/deployment/) or you can use the [whitenoise](http://whitenoise.evans.io/en/stable/django.html) library.
