Commit 1028b24e authored by Laura Morel's avatar Laura Morel
Browse files

Generate random secret key for Django backend

parent 4b779ced
......@@ -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
......
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()
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment