Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
O
oser-backend
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
GitLab community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hamza Touizrat
oser-backend
Commits
4f26b9f2
Commit
4f26b9f2
authored
Mar 20, 2018
by
florimondmanca
Browse files
Options
Downloads
Patches
Plain Diff
store static files on file system again - do not use S3
parent
cccaca80
No related branches found
No related tags found
No related merge requests found
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
oser_backend/aws/backends.py
+4
-3
4 additions, 3 deletions
oser_backend/aws/backends.py
oser_backend/aws/conf.py
+12
-5
12 additions, 5 deletions
oser_backend/aws/conf.py
oser_backend/oser_backend/settings/dev.py
+10
-9
10 additions, 9 deletions
oser_backend/oser_backend/settings/dev.py
with
26 additions
and
17 deletions
oser_backend/aws/backends.py
+
4
−
3
View file @
4f26b9f2
...
@@ -7,9 +7,10 @@ directories in the S3 bucket (defined by the 'location' below).
...
@@ -7,9 +7,10 @@ directories in the S3 bucket (defined by the 'location' below).
from
storages.backends.s3boto3
import
S3Boto3Storage
from
storages.backends.s3boto3
import
S3Boto3Storage
def
StaticBackend
():
# uncomment and update aws/conf.py to use for storing static files on AWS
"""
Static storage backend.
"""
# def StaticBackend():
return
S3Boto3Storage
(
location
=
'
static
'
)
# """Static storage backend."""
# return S3Boto3Storage(location='static')
def
MediaBackend
():
def
MediaBackend
():
...
...
This diff is collapsed.
Click to expand it.
oser_backend/aws/conf.py
+
12
−
5
View file @
4f26b9f2
...
@@ -9,7 +9,16 @@ import os
...
@@ -9,7 +9,16 @@ import os
# Use S3 backends
# Use S3 backends
DEFAULT_FILE_STORAGE
=
'
aws.backends.MediaBackend
'
DEFAULT_FILE_STORAGE
=
'
aws.backends.MediaBackend
'
STATICFILES_STORAGE
=
'
aws.backends.StaticBackend
'
# Uncomment to store static files on AWS
# Beware that Heroku automatically calls 'manage.py collectstatic' for
# each deployment, and this backend does not support checking for pre-existing
# static files on AWS : all the static files will be uploaded on each
# deployment.
# It can be OK to set DISABLE_COLLECTSTATIC on Heroku, but then
# you'd have to run collectstatic manually on Heroku when necessary.
# Since static files on the backend should not change a lot, it seems OK
# to simply use the default file storage for static files.
# STATICFILES_STORAGE = 'aws.backends.StaticBackend'
# Credentials
# Credentials
AWS_ACCESS_KEY_ID
=
os
.
environ
.
get
(
'
AWS_ACCESS_KEY_ID
'
)
AWS_ACCESS_KEY_ID
=
os
.
environ
.
get
(
'
AWS_ACCESS_KEY_ID
'
)
...
@@ -32,10 +41,8 @@ AWS_BASE_URL = (
...
@@ -32,10 +41,8 @@ AWS_BASE_URL = (
'
https://{bucket}.s3.{region}.amazonaws.com/
'
'
https://{bucket}.s3.{region}.amazonaws.com/
'
.
format
(
bucket
=
AWS_STORAGE_BUCKET_NAME
,
region
=
AWS_S3_REGION_NAME
))
.
format
(
bucket
=
AWS_STORAGE_BUCKET_NAME
,
region
=
AWS_S3_REGION_NAME
))
# Redefine media
and static
URL
s
to upload/retrieve to/from S3
# Redefine media URL to upload/retrieve to/from S3
MEDIA_URL
=
AWS_BASE_URL
+
'
media/
'
MEDIA_URL
=
AWS_BASE_URL
+
'
media/
'
STATIC_URL
=
AWS_BASE_URL
+
'
static/
'
# Direct the MEDIA_ROOT
and STATIC_ROOT to their
bucket directory
# Direct the MEDIA_ROOT
to its
bucket directory
MEDIA_ROOT
=
'
media
'
MEDIA_ROOT
=
'
media
'
STATIC_ROOT
=
'
static
'
This diff is collapsed.
Click to expand it.
oser_backend/oser_backend/settings/dev.py
+
10
−
9
View file @
4f26b9f2
...
@@ -148,14 +148,14 @@ MARKDOWNX_MARKDOWN_EXTENSION_CONFIGS = {
...
@@ -148,14 +148,14 @@ MARKDOWNX_MARKDOWN_EXTENSION_CONFIGS = {
}
}
# Database
# Database
# Will be retrieved through the DATABASE_URL environment variable
# Config be retrieved through the DATABASE_URL environment variable
# DATABASE_URL format: postgres://USERNAME:PASSWORD@HOST:PORT/NAME
DATABASES
=
{
DATABASES
=
{
'
default
'
:
dj_database_url
.
config
(
'
default
'
:
dj_database_url
.
config
(
default
=
'
postgres://postgres:postgres@localhost:5432/oser_backend_db
'
),
default
=
'
postgres://postgres:postgres@localhost:5432/oser_backend_db
'
),
}
}
# Security: SSL and HTTPS
# Security
# SECURE_SSL_REDIRECT = True # redirect all to HTTPS
SESSION_COOKIE_SECURE
=
True
SESSION_COOKIE_SECURE
=
True
CSRF_COOKIE_SECURE
=
True
CSRF_COOKIE_SECURE
=
True
SECURE_BROWSER_XSS_FILTER
=
True
SECURE_BROWSER_XSS_FILTER
=
True
...
@@ -194,19 +194,20 @@ USE_I18N = True
...
@@ -194,19 +194,20 @@ USE_I18N = True
USE_L10N
=
True
USE_L10N
=
True
USE_TZ
=
True
USE_TZ
=
True
# Static files (CSS, JavaScript, Images)
# Static files (CSS, JavaScript, Images)
and media files (user-uploaded)
# In development, static and media files are tied to the local filesystem.
# In development, static and media files are tied to the local filesystem.
# In production, media files cannot be stored on Heroku and need
# to be hosted elsewhere (e.g. AWS S3).
# Storage backend (Django's default)
# Static files config
DEFAULT_FILE_STORAGE
=
'
django.core.files.storage.FileSystemStorage
'
STATICFILES_STORAGE
=
'
django.core.files.storage.FileSystemStorage
'
# Static files
STATIC_URL
=
'
/static/
'
STATIC_URL
=
'
/static/
'
STATICFILES_DIRS
=
[
STATICFILES_DIRS
=
[
os
.
path
.
join
(
BASE_DIR
,
'
staticfiles
'
),
os
.
path
.
join
(
BASE_DIR
,
'
staticfiles
'
),
]
]
STATIC_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
'
static
'
)
STATIC_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
'
static
'
)
# User-uploaded media files
# Media files config
DEFAULT_FILE_STORAGE
=
'
django.core.files.storage.FileSystemStorage
'
MEDIA_URL
=
'
/media/
'
MEDIA_URL
=
'
/media/
'
MEDIA_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
'
media
'
)
MEDIA_ROOT
=
os
.
path
.
join
(
BASE_DIR
,
'
media
'
)
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment