Django Static – Google Cloud Storage – CDN


I am still new with serving my Django static/media files to Google cloud storage. It’s working now but I am not sure if this is right or is this enough already, do I still need to use CDN like Cloudfront or other similar services? I am really confused and any recommendation would be much appreciated.

Below is my configuration.

import os
from google.oauth2 import service_account

BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))

GS_CREDENTIALS = service_account.Credentials.from_service_account_file(
os.path.join(BASE_DIR, 'extras/google-storage.json')

STATICFILES_STORAGE = 'extras.storage_backends.GoogleCloudStaticFileStorage'
DEFAULT_FILE_STORAGE = 'extras.storage_backends.GoogleCloudMediaFileStorage'

GS_PROJECT_ID = 'project_id'
GS_STATIC_BUCKET_NAME = 'static_bucket'
GS_MEDIA_BUCKET_NAME = 'media_bucket'

GS_DEFAULT_ACL = 'publicRead'

I am using the following:

Django 2.2

Python 3.7

Thanks you so much!


You won’t need any further services like CDN or CloudFront for your Django media to be used with Cloud Storage. As clarified in the official Django Storage documentation – accessible here – there are a few parameters that you need to have configured to integrate the products and it doesn’t include network services.

Another example of how integrate the two and where this type of service is not recommended is in this article here. So, to summarize, don’t worry, you won’t need this type of network service to continue running your Django files to Cloud Storage.

Answered By – gso_gabriel

This Answer collected from stackoverflow, is licensed under cc by-sa 2.5 , cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply

(*) Required, Your email will not be published