title: Managing static files in Django 3.1
body: <p>There are some changes in the Django 3.1 update and settings file has bee changes a bit as <code>import os</code> has been dropped. I have created a new project on Django 3.1 and referred to the <a href="https://docs.djangoproject.com/en/3.1/howto/static-files/" rel="nofollow noreferrer">official documentation</a> for managing static files. I also tried <a href="https://stackoverflow.com/questions/63436120/django-new-version-3-1-the-settings-file-have-some-changes">this solution</a> from StackOverflow but it didn't work out for me.</p>
  <h3>My project structure:</h3>
  <pre class="lang-sh prettyprint-override"><code>.
  ├── db.sqlite3
  ├── app
  │   ├── admin.py
  │   ├── apps.py
  │   ├── models.py
  │   ├── tests.py
  │   ├── urls.py
  │   └── views.py
  ├── project
  │   ├── asgi.py
  │   ├── __init__.py
  │   ├── settings
  │   │   ├── base.py
  │   │   ├── __init__.py
  │   │   ├── local.py
  │   │   ├── production.py
  │   │   └── __pycache__
  │   ├── urls.py
  │   └── wsgi.py
  ├── manage.py
  ├── static
  │   ├── css
  │   │   └── main.css
  │   └── js
  │       └── fullscreen_toggle.js
  └── templates
  </code></pre>
  <h3>local.py:</h3>
  <pre class="lang-py prettyprint-override"><code>import os
  from pathlib import Path
  
  # Build paths inside the project like this: BASE_DIR / 'subdir'.
  BASE_DIR = Path(__file__).resolve(strict=True).parent.parent
  
  
  # 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 = '----secretKey----'
  
  # SECURITY WARNING: don't run with debug turned on in production!
  DEBUG = True
  
  ALLOWED_HOSTS = ['127.0.0.1','0.0.0.0']
  
  
  # Application definition
  
  INSTALLED_APPS = [
      'django.contrib.admin',
      'django.contrib.auth',
      'django.contrib.contenttypes',
      'django.contrib.sessions',
      'django.contrib.messages',
      'django.contrib.staticfiles',
  ]
  
  MIDDLEWARE = [
      'whitenoise.middleware.WhiteNoiseMiddleware',
      '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 = 'easynotes.urls'
  
  TEMPLATES = [
      {
          'BACKEND': 'django.template.backends.django.DjangoTemplates',
          'DIRS': ['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 = 'easynotes.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 = 'Asia/Kolkata'
  
  USE_I18N = True
  
  USE_L10N = True
  
  USE_TZ = True
  
  APPEND_SLASH = False
  
  # Static files (CSS, JavaScript, Images)
  # https://docs.djangoproject.com/en/3.1/howto/static-files/
  
  STATIC_URL = '/static/'
  
  STATICFILES_DIRS = (
      os.path.join(BASE_DIR, &quot;static&quot;),
  )
  
  STATIC_ROOT = os.path.join(BASE_DIR, &quot;live-static&quot;, &quot;static-root&quot;)
  
  STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage'
  
  MEDIA_URL = &quot;/media/&quot;
  
  MEDIA_ROOT = os.path.join(BASE_DIR, &quot;live-static&quot;, &quot;media-root&quot;)
  </code></pre>
  <h3>Console output in inspect element:</h3>
  <pre class="lang-js prettyprint-override"><code>GET http://127.0.0.1:8000/static/js/fullscreen_toggle.js net::ERR_ABORTED 404 (Not Found)
  </code></pre>