title: Django production static files are not working (deployment)
body: <p>When deploying my Django project in the Linux server, the static files are not getting uploaded. I have followed instructions on the Docs but it doesn't seem to work. </p>
  
  <p><strong>This is what I had done so far:</strong></p>
  
  <p><strong>settings.py:</strong></p>
  
  <pre><code>DEBUG = False
  
  .....
  
  STATIC_URL = '/static/'
  
  STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')  
  
  MEDIA_URL = '/media/'
  MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
  </code></pre>
  
  <p><strong>urls.py:</strong></p>
  
  <pre><code>urlpatterns = [
      path('admin/', admin.site.urls),
      #remaining urls here....
  ]
  
  if settings.DEBUG:
      urlpatterns = urlpatterns + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
      urlpatterns = urlpatterns + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
  </code></pre>
  
  <p><strong>For deploying static files, I typed this command:</strong></p>
  
  <pre><code>python manage.py collectstatic
  </code></pre>
  
  <p>All the files are being pushed to a directory called 'staticfiles' in the root folder and the command works as expected.</p>
  
  <p>However, when starting the Django server, all the static files i.e JS, CSS and media files are not seen. In fact, the site is broken. But when the Debug mode is <strong>set to True</strong>, then the site works well again. </p>
  
  <p>What went wrong? Can anyone let me know where I am making a mistake? </p>