Commit 6cba08e4 authored by Laura Morel's avatar Laura Morel
Browse files

Fix Django container

parent 19c85483
...@@ -11,8 +11,6 @@ WORKDIR /code ...@@ -11,8 +11,6 @@ WORKDIR /code
COPY . /code/ COPY . /code/
RUN python3.8 manage.py generate_secret_key RUN python3.8 generate_secret_key.py
RUN python3.8 manage.py makemigrations
RUN python3.8 manage.py migrate --run-syncdb && python manage.py fill_db True
EXPOSE 8000 EXPOSE 8000
...@@ -15,9 +15,9 @@ class Command(BaseCommand): ...@@ -15,9 +15,9 @@ class Command(BaseCommand):
sizes = [10, 15, 20] sizes = [10, 15, 20]
def add_arguments(self, parser): def add_arguments(self, parser):
parser.add_argument('verbose', type=bool) parser.add_argument('verbose', type=bool, nargs='?', default=False)
def fill_db(self, verbose=False): def fill_db(self, verbose):
for sp in self.species: for sp in self.species:
if verbose: if verbose:
print(sp) print(sp)
......
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()
from django.core.management.utils import get_random_secret_key
key=get_random_secret_key()
with open(".env", "w") as f:
f.write("SECRET_KEY='%s'\n" %(key))
f.close()
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