Skip to content

Commit

Permalink
Merge pull request #112 from OpenUnited/setup-s3
Browse files Browse the repository at this point in the history
Update the settings
  • Loading branch information
dogukanteber authored Oct 22, 2023
2 parents e7cd17d + d128f93 commit f8ee34f
Showing 1 changed file with 22 additions and 7 deletions.
29 changes: 22 additions & 7 deletions openunited/settings/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,13 +145,28 @@
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/4.2/howto/static-files/

STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")

STATIC_URL = "static/"

STATICFILES_DIRS = [
BASE_DIR / "static",
]
if os.getenv("AWS_STORAGE_BUCKET_NAME"):
# AWS S3 Static File Configuration
AWS_ACCESS_KEY_ID = os.getenv("AWS_ACCESS_KEY_ID")
AWS_SECRET_ACCESS_KEY = os.getenv("AWS_SECRET_ACCESS_KEY")
AWS_STORAGE_BUCKET_NAME = os.getenv("AWS_STORAGE_BUCKET_NAME")
AWS_S3_ENDPOINT_URL = os.getenv("AWS_S3_ENDPOINT_URL")
AWS_S3_OBJECT_PARAMETERS = {
"CacheControl": "max-age=86400",
}
AWS_LOCATION = "openunited-static"

STATICFILES_DIRS = [
os.path.join(BASE_DIR, "static"),
]
STATIC_URL = "https://%s/%s/" % (AWS_S3_ENDPOINT_URL, AWS_LOCATION)
STATICFILES_STORAGE = "storages.backends.s3boto3.S3Boto3Storage"
else:
STATIC_ROOT = os.path.join(BASE_DIR, "staticfiles")
STATIC_URL = "static/"
STATICFILES_DIRS = [
BASE_DIR / "static",
]

MEDIA_URL = "/media/"

Expand Down

0 comments on commit f8ee34f

Please sign in to comment.