Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Laura Morel
VizFaDa-app
Commits
1028b24e
Commit
1028b24e
authored
Nov 23, 2020
by
Laura Morel
Browse files
Generate random secret key for Django backend
parent
4b779ced
Changes
2
Hide whitespace changes
Inline
Side-by-side
Django/Dockerfile
View file @
1028b24e
...
...
@@ -11,6 +11,7 @@ WORKDIR /code
COPY
. /code/
RUN
python3.8 manage.py generate_secret_key
RUN
python3.8 manage.py makemigrations
RUN
python3.8 manage.py migrate
--run-syncdb
&&
python manage.py fill_db True
...
...
Django/data/management/commands/generate_secret_key.py
0 → 100644
View file @
1028b24e
from
django.core.management.base
import
BaseCommand
,
CommandError
from
django.core.management.utils
import
get_random_secret_key
class
Command
(
BaseCommand
):
def
generate_secret_key
(
self
):
key
=
get_random_secret_key
()
with
open
(
".env"
,
"w"
)
as
f
:
f
.
write
(
"SECRET_KEY='%s'
\n
"
%
(
key
))
f
.
close
()
def
handle
(
self
,
**
options
):
self
.
generate_secret_key
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment