create management command to create test users, use it in Docker
This commit is contained in:
parent
d3ade15c9a
commit
d13d3f53d5
5 changed files with 29 additions and 2 deletions
|
@ -13,4 +13,4 @@ ADD requirements.txt /site/
|
|||
RUN pip install -U -r /site/requirements.txt
|
||||
|
||||
COPY ./ /site
|
||||
CMD bash -c 'python3 manage.py migrate --noinput && python3 manage.py collectstatic --noinput && uwsgi --ini=/site/uwsgi.ini'
|
||||
CMD bash -c 'python3 manage.py migrate --noinput && python3 manage.py collectstatic --noinput && python3 manage.py create_test_users && uwsgi --ini=/site/uwsgi.ini'
|
||||
|
|
|
@ -1,3 +1,5 @@
|
|||
docker build -t ipv6dotwork .
|
||||
|
||||
docker run -d -p 127.0.0.1:8001:8000 --name ipv6dotwork ipv6dotwork
|
||||
sudo docker rm -f ipv6dotwork
|
||||
|
||||
sudo docker run -d -p 127.0.0.1:8001:8000 --env-file .env --name ipv6dotwork ipv6dotwork
|
0
jobs/management/__init__.py
Normal file
0
jobs/management/__init__.py
Normal file
0
jobs/management/commands/__init__.py
Normal file
0
jobs/management/commands/__init__.py
Normal file
25
jobs/management/commands/create_test_users.py
Normal file
25
jobs/management/commands/create_test_users.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
from django.core.management import BaseCommand
|
||||
from django.contrib.auth import get_user_model
|
||||
|
||||
User = get_user_model()
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = "Create test accounts. Don't use this in production!"
|
||||
|
||||
def handle(self, *args, **options):
|
||||
user_fixture = [
|
||||
{
|
||||
'username': 'user1',
|
||||
'email': 'user1@dev.ipv6.work',
|
||||
'password': 'user1'
|
||||
},
|
||||
{
|
||||
'username': 'user2',
|
||||
'email': 'user2@dev.ipv6.work',
|
||||
'password': 'user2'
|
||||
},
|
||||
]
|
||||
|
||||
for user_data in user_fixture:
|
||||
User.objects.create_user(**user_data)
|
Loading…
Reference in a new issue