Skip to content

Instantly share code, notes, and snippets.

@raunak-r
Last active August 19, 2021 13:34
Show Gist options
  • Save raunak-r/6d69e2cfdf18b4751397bc38f9c96691 to your computer and use it in GitHub Desktop.
Save raunak-r/6d69e2cfdf18b4751397bc38f9c96691 to your computer and use it in GitHub Desktop.
Django setting DEBUG=True in production.

Setting DEBUG=True in a Django Project.

Locally, change the DEBUG property in settings.py to True.

Make sure you have the following properties set in settings.py:

The URL to use when referring to static files (where they will be served from) STATIC_URL = '/static/'

The absolute path to the directory where collectstatic will collect static files for deployment. STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')

Extra places for collectstatic to find static files. STATICFILES_DIRS = ( os.path.join(BASE_DIR, 'static'), )

Simplified static file serving. https://warehouse.python.org/project/whitenoise/ STATICFILES_STORAGE = 'whitenoise.storage.CompressedManifestStaticFilesStorage' Locally, add a folder named static to the root folder.

Locally, run python manage.py collectstatic. This should create another folder in your app's root folder called staticfiles.

Now you can set the DEBUG property in settings.py to False and deploy your app.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment